forked from swapnil.bendal/TypeScript-Backend-Template
[fixed] - eslint
This commit is contained in:
@@ -1,32 +1,33 @@
|
||||
class ApiError<T = any> extends Error {
|
||||
statusCode: number;
|
||||
data: T | null;
|
||||
message: string;
|
||||
success: boolean;
|
||||
errors: Array<any>;
|
||||
isOperational: boolean;
|
||||
stack?: string;
|
||||
class ApiError<T = unknown> extends Error {
|
||||
statusCode: number;
|
||||
data: T | null;
|
||||
message: string;
|
||||
success: boolean;
|
||||
errors: Array<unknown>;
|
||||
isOperational: boolean;
|
||||
stack?: string;
|
||||
|
||||
constructor(
|
||||
statusCode: number,
|
||||
message: string = 'Something went wrong',
|
||||
errors: Array<any> = [],
|
||||
isOperational: boolean = true,
|
||||
stack: string = ''
|
||||
) {
|
||||
super(message);
|
||||
this.statusCode = statusCode;
|
||||
this.data = null;
|
||||
this.message = message;
|
||||
this.success = false;
|
||||
this.errors = errors;
|
||||
this.isOperational = isOperational;
|
||||
constructor(
|
||||
statusCode: number,
|
||||
message: string = 'Something went wrong',
|
||||
errors: Array<unknown> = [],
|
||||
isOperational: boolean = true,
|
||||
stack?: string
|
||||
) {
|
||||
super(message);
|
||||
this.statusCode = statusCode;
|
||||
this.data = null;
|
||||
this.message = message;
|
||||
this.success = false;
|
||||
this.errors = errors;
|
||||
this.isOperational = isOperational;
|
||||
|
||||
if (stack) {
|
||||
this.stack = stack;
|
||||
} else {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
}
|
||||
if (stack) {
|
||||
this.stack = stack;
|
||||
} else {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
}
|
||||
}
|
||||
export default ApiError;
|
||||
|
||||
export default ApiError;
|
||||
|
||||
Reference in New Issue
Block a user