SEC_Warehouse/src/http/errors.ts

24 lines
630 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 网络/HTTP 错误
export class ApiError extends Error {
constructor(message: string, public readonly statusCode?: number) {
super(message)
this.name = 'ApiError'
}
}
// 业务错误(后端 Code 为字符串,如 '200'/'500'/'401')
export class BusinessError extends Error {
constructor(message: string, public readonly code: string) {
super(message)
this.name = 'BusinessError'
}
}
// 登录态失效(HTTP 401 或业务码 401),触发踢回登录页
export class AuthExpiredError extends Error {
constructor(message: string) {
super(message)
this.name = 'AuthExpiredError'
}
}