Skip to content

Commit

Permalink
fix: filter non error type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
MoumitaM committed Sep 26, 2024
1 parent ed32560 commit faf2e52
Showing 1 changed file with 0 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,12 @@ const getStacktrace = (error: any, errorFramesToSkip: number) => {
return [];
};

const hasNecessaryFields = (error: any) =>
(typeof error.name === 'string' || typeof error.errorClass === 'string') &&
(typeof error.message === 'string' || typeof error.errorMessage === 'string');

const normaliseError = (maybeError: any, component: string, logger?: ILogger) => {
let error;
let internalFrames = 0;

if (isError(maybeError)) {
error = maybeError;
} else if (typeof maybeError === 'object' && hasNecessaryFields(maybeError)) {
error = new Error(maybeError.message || maybeError.errorMessage);
error.name = maybeError.name || maybeError.errorClass;
internalFrames += 1;
} else {
logger?.warn(
`${ERROR_REPORTING_PLUGIN}:: ${component} received a non-error: ${stringifyWithoutCircular(error)}`,
Expand Down

0 comments on commit faf2e52

Please sign in to comment.