feat(error-handling): Modified error-handling to show better types of errors
This commit is contained in:
@@ -36,11 +36,20 @@ export class CustomError implements Error {
|
||||
return error as any;
|
||||
}
|
||||
}
|
||||
|
||||
static getErrorType(error: Error): ErrorType {
|
||||
let type = (error as any).type || ErrorType.UNKNOWN;
|
||||
|
||||
if (error.name === 'HttpErrorResponse') {
|
||||
type = ErrorType.API;
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
export function errorToCustomError(error: Error): CustomError {
|
||||
console.log(error);
|
||||
const type = (error as any).type || ErrorType.UNKNOWN;
|
||||
const type = CustomError.getErrorType(error);
|
||||
const message = error.message || (error as any);
|
||||
const severity = ErrorSeverity.HIGH;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user