types for error handler

This commit is contained in:
Dan Ribbens
2020-12-01 09:46:57 -05:00
parent bb7c829c5e
commit 6b61714d7e
5 changed files with 16 additions and 16 deletions

View File

@@ -7,13 +7,13 @@ import httpStatus from 'http-status';
class ExtendableError extends Error {
status: number;
data: any;
data: {[key: string]: unknown};
isPublic: boolean;
isOperational: boolean;
constructor(message: string, status: number, data: any, isPublic: boolean) {
constructor(message: string, status: number, data: { [key: string]: unknown }, isPublic: boolean) {
super(message);
this.name = this.constructor.name;
this.message = message;
@@ -39,7 +39,7 @@ class APIError extends ExtendableError {
* @param {object} data - response data to be returned.
* @param {boolean} isPublic - Whether the message should be visible to user or not.
*/
constructor(message: string, status: number = httpStatus.INTERNAL_SERVER_ERROR, data: any = null, isPublic = false) {
constructor(message: string, status: number = httpStatus.INTERNAL_SERVER_ERROR, data: { [key: string]: unknown } = null, isPublic = false) {
super(message, status, data, isPublic);
}
}