Skip to content

Commit

Permalink
chore: change to display error message without undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
gutyerrez committed Nov 13, 2024
1 parent 3b36aac commit cadacf7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import i18next from 'i18next';

export class Exception {
export class Exception extends Error {
public readonly status: number;
public readonly name: string;
public readonly message: string | undefined;

constructor(status: number, name: string, parameters?: Record<string, string | number>, message?: string) {
super(i18next.t(message ?? name, parameters));

this.status = status;
this.name = name;
this.message = i18next.t(message ?? name, parameters);

this.stack = message ?? name;
}
}

0 comments on commit cadacf7

Please sign in to comment.