export class AuthError extends Error { constructor( public readonly code: string, message: string, public readonly httpStatus: number, ) { super(message); this.name = "AuthError"; } } export function unauthorized(message = "未授权"): AuthError { return new AuthError("UNAUTHORIZED", message, 401); } export function forbidden(message = "无权访问"): AuthError { return new AuthError("FORBIDDEN", message, 403); }