mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-04 21:04:37 +08:00
StatusError name
This commit is contained in:
parent
075ca1d303
commit
02fe7bee2f
@ -21,6 +21,8 @@ export type KnownErrorConstructor<Instance extends KnownError, Args extends any[
|
||||
};
|
||||
|
||||
export abstract class KnownError extends StatusError {
|
||||
public name = "KnownError";
|
||||
|
||||
constructor(
|
||||
public readonly statusCode: number,
|
||||
public readonly humanReadableMessage: string,
|
||||
@ -112,6 +114,7 @@ function createKnownErrorConstructor<ErrorCode extends string, Super extends Abs
|
||||
// @ts-expect-error this is not a mixin, but TS detects it as one
|
||||
class KnownErrorImpl extends SuperClass {
|
||||
public static readonly errorCode = errorCode;
|
||||
public name = `KnownError<${errorCode}>`;
|
||||
|
||||
constructor(...args: Args) {
|
||||
// @ts-expect-error
|
||||
|
||||
@ -17,6 +17,7 @@ export function throwErr(...args: any[]): never {
|
||||
|
||||
|
||||
export class StackAssertionError extends Error {
|
||||
public name = "StackAssertionError";
|
||||
constructor(message: string, public readonly extraData?: Record<string, any>, options?: ErrorOptions) {
|
||||
super(`${message}\n\nThis is likely an error in Stack. Please report it.`, options);
|
||||
}
|
||||
@ -54,6 +55,7 @@ type StatusErrorConstructorParameters = [
|
||||
];
|
||||
|
||||
export class StatusError extends Error {
|
||||
public name = "StatusError";
|
||||
public readonly statusCode: number;
|
||||
|
||||
public static BadRequest = { statusCode: 400, message: "Bad Request" };
|
||||
|
||||
Loading…
Reference in New Issue
Block a user