style: format code biome
This commit is contained in:
1 parent
8efd032cc6
commit
df38dccbf1
735 files changed
+128321
-120870
No files matched your search
@@ -1,67 +1,67 @@
|
||||
export class DomainError extends Error {
|
||||
public readonly status: number;
|
||||
public readonly status: number;
|
||||
|
||||
constructor(message: string, status: number = 500) {
|
||||
super(message);
|
||||
this.name = "DomainError";
|
||||
this.status = status;
|
||||
}
|
||||
constructor(message: string, status: number = 500) {
|
||||
super(message);
|
||||
this.name = "DomainError";
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
|
||||
export class NotFoundError extends DomainError {
|
||||
constructor(entity: string, id?: number | string) {
|
||||
super(id ? `${entity} #${id} not found` : `${entity} not found`, 404);
|
||||
this.name = "NotFoundError";
|
||||
}
|
||||
constructor(entity: string, id?: number | string) {
|
||||
super(id ? `${entity} #${id} not found` : `${entity} not found`, 404);
|
||||
this.name = "NotFoundError";
|
||||
}
|
||||
}
|
||||
|
||||
export class UnauthorizedError extends DomainError {
|
||||
constructor(message: string = "Unauthorized") {
|
||||
super(message, 401);
|
||||
this.name = "UnauthorizedError";
|
||||
}
|
||||
constructor(message: string = "Unauthorized") {
|
||||
super(message, 401);
|
||||
this.name = "UnauthorizedError";
|
||||
}
|
||||
}
|
||||
|
||||
export class ForbiddenError extends DomainError {
|
||||
constructor(message: string = "Forbidden") {
|
||||
super(message, 403);
|
||||
this.name = "ForbiddenError";
|
||||
}
|
||||
constructor(message: string = "Forbidden") {
|
||||
super(message, 403);
|
||||
this.name = "ForbiddenError";
|
||||
}
|
||||
}
|
||||
|
||||
export class ValidationError extends DomainError {
|
||||
public readonly fieldErrors: Record<string, string[]>;
|
||||
public readonly fieldErrors: Record<string, string[]>;
|
||||
|
||||
constructor(fieldErrors: Record<string, string[]>) {
|
||||
super("Validation failed", 422);
|
||||
this.name = "ValidationError";
|
||||
this.fieldErrors = fieldErrors;
|
||||
}
|
||||
constructor(fieldErrors: Record<string, string[]>) {
|
||||
super("Validation failed", 422);
|
||||
this.name = "ValidationError";
|
||||
this.fieldErrors = fieldErrors;
|
||||
}
|
||||
}
|
||||
|
||||
export class RateLimitError extends DomainError {
|
||||
public readonly retryAfter: number;
|
||||
public readonly retryAfter: number;
|
||||
|
||||
constructor(retryAfter: number) {
|
||||
super(`Rate limited. Try again in ${retryAfter}s.`, 429);
|
||||
this.name = "RateLimitError";
|
||||
this.retryAfter = retryAfter;
|
||||
}
|
||||
constructor(retryAfter: number) {
|
||||
super(`Rate limited. Try again in ${retryAfter}s.`, 429);
|
||||
this.name = "RateLimitError";
|
||||
this.retryAfter = retryAfter;
|
||||
}
|
||||
}
|
||||
|
||||
export class ConflictError extends DomainError {
|
||||
constructor(message: string) {
|
||||
super(message, 409);
|
||||
this.name = "ConflictError";
|
||||
}
|
||||
constructor(message: string) {
|
||||
super(message, 409);
|
||||
this.name = "ConflictError";
|
||||
}
|
||||
}
|
||||
|
||||
export class DatabaseError extends DomainError {
|
||||
public readonly cause: unknown;
|
||||
public readonly cause: unknown;
|
||||
|
||||
constructor(message: string, cause?: unknown) {
|
||||
super(message, 500);
|
||||
this.name = "DatabaseError";
|
||||
this.cause = cause;
|
||||
}
|
||||
constructor(message: string, cause?: unknown) {
|
||||
super(message, 500);
|
||||
this.name = "DatabaseError";
|
||||
this.cause = cause;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user