Skip to content

Commit

Permalink
chore: add try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurgeron committed Jan 27, 2025
1 parent 9de0762 commit e1ac30a
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions packages/app/src/systems/Error/utils/getErrorIgnoreData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,23 @@ type IgnoredError = {
export function getErrorIgnoreData(
error: Error | undefined
): IgnoredError | undefined {
return IGNORED_ERRORS.find((filter) => {
const errorValue = error?.[filter.field] as string | undefined;
try {
return IGNORED_ERRORS.find((filter) => {
const errorValue = error?.[filter.field] as string | undefined;

switch (filter.comparison) {
case 'exact':
return filter.value === errorValue;
case 'startsWith':
return errorValue?.startsWith(filter.value);
case 'partial':
return errorValue?.includes(filter.value);
}
});
switch (filter.comparison) {
case 'exact':
return filter.value === errorValue;
case 'startsWith':
return errorValue?.startsWith(filter.value);
case 'partial':
return errorValue?.includes(filter.value);
}
});
} catch (error) {
console.warn(error);
return undefined;
}
}

const IGNORED_ERRORS: IgnoredError[] = [
Expand Down

0 comments on commit e1ac30a

Please sign in to comment.