fix custom errors having the wrong name in stack traces
This commit is contained in:
parent
73f672ff79
commit
5f50f51426
15 changed files with 58 additions and 30 deletions
|
|
@ -768,6 +768,9 @@ export class CustomEmojiService {
|
|||
}
|
||||
|
||||
export class InvalidEmojiError extends Error {
|
||||
// Fix the error name in stack traces - https://stackoverflow.com/a/71573071
|
||||
override name = this.constructor.name;
|
||||
|
||||
public readonly [isRetryableSymbol] = false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ export const captchaErrorCodes = {
|
|||
export type CaptchaErrorCode = typeof captchaErrorCodes[keyof typeof captchaErrorCodes];
|
||||
|
||||
export class CaptchaError extends Error {
|
||||
// Fix the error name in stack traces - https://stackoverflow.com/a/71573071
|
||||
override name = this.constructor.name;
|
||||
|
||||
public readonly code: CaptchaErrorCode;
|
||||
public readonly cause?: unknown;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,4 +3,7 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class ConflictError extends Error {}
|
||||
export class ConflictError extends Error {
|
||||
// Fix the error name in stack traces - https://stackoverflow.com/a/71573071
|
||||
override name = this.constructor.name;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@
|
|||
* Common base class for DisposedError and DisposingError - please use only for catch() blocks.
|
||||
*/
|
||||
export abstract class DisposeError extends Error {
|
||||
// Fix the error name in stack traces - https://stackoverflow.com/a/71573071
|
||||
override name = this.constructor.name;
|
||||
|
||||
public readonly source: string | undefined;
|
||||
|
||||
protected constructor(opts?: { source?: string, message?: string }) {
|
||||
|
|
@ -19,6 +22,9 @@ export abstract class DisposeError extends Error {
|
|||
* Thrown when an attempt is made to use an object that has been disposed.
|
||||
*/
|
||||
export class DisposedError extends DisposeError {
|
||||
// Fix the error name in stack traces - https://stackoverflow.com/a/71573071
|
||||
override name = this.constructor.name;
|
||||
|
||||
constructor(opts?: { source?: string, message?: string }) {
|
||||
super({
|
||||
source: opts?.source,
|
||||
|
|
@ -31,6 +37,9 @@ export class DisposedError extends DisposeError {
|
|||
* Thrown when an object is use begins disposing.
|
||||
*/
|
||||
export class DisposingError extends DisposeError {
|
||||
// Fix the error name in stack traces - https://stackoverflow.com/a/71573071
|
||||
override name = this.constructor.name;
|
||||
|
||||
constructor(opts?: { source?: string, message?: string }) {
|
||||
super({
|
||||
source: opts?.source,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@ import { QuantumCacheError } from '@/misc/errors/QuantumCacheError.js';
|
|||
* Thrown when a fetch failed for any reason.
|
||||
*/
|
||||
export class FetchFailedError extends QuantumCacheError {
|
||||
// Fix the error name in stack traces - https://stackoverflow.com/a/71573071
|
||||
override name = this.constructor.name;
|
||||
|
||||
|
||||
/**
|
||||
* Name of the key(s) that could not be fetched.
|
||||
* Will be an array if bulkFetcher() failed, and a string if regular fetch() failed.
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ import { isRetryableSymbol } from '@/misc/is-retryable-error.js';
|
|||
* Thrown when a fetch failed because no value was found for the requested key(s).
|
||||
*/
|
||||
export class KeyNotFoundError extends FetchFailedError {
|
||||
// Fix the error name in stack traces - https://stackoverflow.com/a/71573071
|
||||
override name = this.constructor.name;
|
||||
|
||||
/**
|
||||
* Missing keys are considered non-retryable, as they won't suddenly appear unless something external creates them.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
* Base class for all Quantum Cache errors.
|
||||
*/
|
||||
export class QuantumCacheError extends Error {
|
||||
// Fix the error name in stack traces - https://stackoverflow.com/a/71573071
|
||||
override name = this.constructor.name;
|
||||
|
||||
/**
|
||||
* Name of the cache that produced this error.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
|
||||
// https://www.fastify.io/docs/latest/Reference/Reply/#async-await-and-promises
|
||||
export class FastifyReplyError extends Error {
|
||||
// Fix the error name in stack traces - https://stackoverflow.com/a/71573071
|
||||
override name = this.constructor.name;
|
||||
|
||||
public message: string;
|
||||
public statusCode: number;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@
|
|||
* ID付きエラー
|
||||
*/
|
||||
export class IdentifiableError extends Error {
|
||||
// Fix the error name in stack traces - https://stackoverflow.com/a/71573071
|
||||
override name = this.constructor.name;
|
||||
|
||||
public message: string;
|
||||
public id: string;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
*/
|
||||
|
||||
export class StatusError extends Error {
|
||||
// Fix the error name in stack traces - https://stackoverflow.com/a/71573071
|
||||
override name = this.constructor.name;
|
||||
|
||||
public statusCode: number;
|
||||
public statusMessage?: string;
|
||||
public isClientError: boolean;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@ import { CacheManagementService, type ManagedMemoryKVCache } from '@/global/Cach
|
|||
import { TimeService } from '@/global/TimeService.js';
|
||||
|
||||
export class AuthenticationError extends Error {
|
||||
// Fix the error name in stack traces - https://stackoverflow.com/a/71573071
|
||||
override name = this.constructor.name;
|
||||
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
this.name = 'AuthenticationError';
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@
|
|||
type E = { message: string, code: string, id: string, kind?: 'client' | 'server' | 'permission', httpStatusCode?: number };
|
||||
|
||||
export class ApiError extends Error {
|
||||
// Fix the error name in stack traces - https://stackoverflow.com/a/71573071
|
||||
override name = this.constructor.name;
|
||||
|
||||
public message: string;
|
||||
public code: string;
|
||||
public id: string;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue