refactor(core): standardize frontend error handling (#10667)

This commit is contained in:
forehalo
2025-03-06 13:10:18 +00:00
parent 2e86bfffae
commit e02fb4fa94
70 changed files with 495 additions and 480 deletions

View File

@@ -5,6 +5,7 @@ import { HttpStatus, Logger } from '@nestjs/common';
import { ClsServiceManager } from 'nestjs-cls';
export type UserFriendlyErrorBaseType =
| 'network_error'
| 'bad_request'
| 'too_many_requests'
| 'resource_not_found'
@@ -26,6 +27,7 @@ export type UserFriendlyErrorOptions = {
};
const BaseTypeToHttpStatusMap: Record<UserFriendlyErrorBaseType, HttpStatus> = {
network_error: HttpStatus.GATEWAY_TIMEOUT,
too_many_requests: HttpStatus.TOO_MANY_REQUESTS,
bad_request: HttpStatus.BAD_REQUEST,
resource_not_found: HttpStatus.NOT_FOUND,
@@ -239,6 +241,10 @@ export const USER_FRIENDLY_ERRORS = {
type: 'internal_server_error',
message: 'An internal error occurred.',
},
network_error: {
type: 'network_error',
message: 'Network error.',
},
too_many_request: {
type: 'too_many_requests',
message: 'Too many requests.',