Skip to content

Commit

Permalink
feat: track passport starkex transfer errors (#2043)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeSchwert authored Jul 31, 2024
1 parent 3c374e6 commit e650695
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion packages/passport/sdk/src/errors/passportError.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { isAxiosError } from 'axios';
import { imx } from '@imtbl/generated-clients';
import { trackError } from '@imtbl/metrics';

export enum PassportErrorType {
AUTHENTICATION_ERROR = 'AUTHENTICATION_ERROR',
Expand Down Expand Up @@ -40,6 +41,7 @@ export class PassportError extends Error {
export const withPassportError = async <T>(
fn: () => Promise<T>,
customErrorType: PassportErrorType,
customEventName?: string,
): Promise<T> => {
try {
return await fn();
Expand All @@ -52,6 +54,12 @@ export const withPassportError = async <T>(
errorMessage = (error as Error).message;
}

throw new PassportError(errorMessage, customErrorType);
const passportError = new PassportError(errorMessage, customErrorType);

if (customEventName) {
trackError('passport', customEventName, passportError);
}

throw passportError;
}
};
4 changes: 2 additions & 2 deletions packages/passport/sdk/src/starkEx/workflows/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export async function transfer({
time: responseData.time,
transfer_id: responseData.transfer_id,
};
}, PassportErrorType.TRANSFER_ERROR);
}, PassportErrorType.TRANSFER_ERROR, 'imxTransfer');
}

export async function batchNftTransfer({
Expand Down Expand Up @@ -161,5 +161,5 @@ export async function batchNftTransfer({
return {
transfer_ids: response?.data.transfer_ids,
};
}, PassportErrorType.TRANSFER_ERROR);
}, PassportErrorType.TRANSFER_ERROR, 'imxBatchNftTransfer');
}

0 comments on commit e650695

Please sign in to comment.