mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
refactor(core): standardize frontend error handling (#10667)
This commit is contained in:
@@ -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.',
|
||||
|
||||
Reference in New Issue
Block a user