You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
451 B
19 lines
451 B
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);
|
|
}
|