diff --git a/apps/dafa-web/src/app/data/models/error/custom-error.ts b/apps/dafa-web/src/app/data/models/error/custom-error.ts index 3da9600..14ca260 100644 --- a/apps/dafa-web/src/app/data/models/error/custom-error.ts +++ b/apps/dafa-web/src/app/data/models/error/custom-error.ts @@ -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;