Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
neSpecc committed Oct 12, 2024
1 parent a20a955 commit 58a6c9c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
6 changes: 2 additions & 4 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ export async function callOld(
let response;

try { // handle axios errors

if (initial || force) {
response = await promise;
} else {
Expand All @@ -154,7 +153,7 @@ export async function callOld(
'Request': request,
'Error Path': error.path,
'Variables': variables ?? {},
'Response Data': response.data.data
'Response Data': response.data.data,
});

printApiError(error, response.data, request, variables);
Expand All @@ -177,15 +176,14 @@ export async function callOld(
* @deprecated old format. See method jsdoc
*/
return response.data.data;

} catch (error) {
console.error('API Request Error', error);

track(error as Error, {
request,
variables: variables ?? {},
response: response?.data,
})
});
throw error;
}
}
Expand Down
15 changes: 9 additions & 6 deletions src/hawk.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import HawkCatcher, { HawkInitialSettings, HawkJavaScriptEvent } from '@hawk.so/javascript';
import HawkCatcher, { HawkInitialSettings, HawkJavaScriptEvent } from '@hawk.so/javascript'
import type Vue from 'vue';

/**
Expand Down Expand Up @@ -31,7 +31,10 @@ let hawk: HawkCatcher | null = null;
/**
* Composable for tracking errors via Hawk.so
*/
export function useErrorTracker() {
export function useErrorTracker(): {
initHawk: (options: ErrorTrackerInitialOptions) => void;
track: (...args: Parameters<HawkCatcher['send']>) => void;
} {
/**
* Initialize Hawk.so
*
Expand Down Expand Up @@ -59,14 +62,14 @@ export function useErrorTracker() {
* @param error - error to track
* @param context - additional context
*/
function track(error: Parameters<HawkCatcher['send']>[0], context?: Parameters<HawkCatcher['send']>[1]): void {
function track(...args: Parameters<HawkCatcher['send']>): void {
if (hawk) {
hawk.send(error, context);
hawk.send(...args);
}
}

return {
initHawk,
track
}
track,
};
}

0 comments on commit 58a6c9c

Please sign in to comment.