diff --git a/src/errors/APIError.ts b/src/errors/APIError.ts index b889d164ba..dca496770f 100644 --- a/src/errors/APIError.ts +++ b/src/errors/APIError.ts @@ -5,6 +5,14 @@ import httpStatus from 'http-status'; * @extends Error */ class ExtendableError extends Error { + status: number; + + data: any; + + isPublic: boolean; + + isOperational: boolean; + constructor(message: string, status: number, data: any, isPublic: boolean) { super(message); this.name = this.constructor.name; @@ -13,6 +21,8 @@ class ExtendableError extends Error { this.data = data; this.isPublic = isPublic; this.isOperational = true; // This is required since bluebird 4 doesn't append it anymore. + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore Couldn't get the compiler to love me Error.captureStackTrace(this, this.constructor.name); } } diff --git a/src/errors/DuplicateCollection.ts b/src/errors/DuplicateCollection.ts index f13ce750de..5c0f43e854 100644 --- a/src/errors/DuplicateCollection.ts +++ b/src/errors/DuplicateCollection.ts @@ -1,7 +1,7 @@ import APIError from './APIError'; class DuplicateCollection extends APIError { - constructor(propertyName, duplicates) { + constructor(propertyName: string, duplicates: string[]) { super(`Collection ${propertyName} already in use: "${duplicates.join(', ')}"`); } } diff --git a/src/errors/DuplicateGlobal.ts b/src/errors/DuplicateGlobal.ts index f33aee7dbf..baaae40019 100644 --- a/src/errors/DuplicateGlobal.ts +++ b/src/errors/DuplicateGlobal.ts @@ -1,7 +1,8 @@ +import { Global } from '../globals/config/types'; import APIError from './APIError'; class DuplicateGlobal extends APIError { - constructor(config) { + constructor(config: Global) { super(`Global label "${config.label}" is already in use`); } } diff --git a/src/errors/InvalidConfiguration.ts b/src/errors/InvalidConfiguration.ts index f2b85277df..1ceff282cb 100644 --- a/src/errors/InvalidConfiguration.ts +++ b/src/errors/InvalidConfiguration.ts @@ -2,7 +2,7 @@ import httpStatus from 'http-status'; import APIError from './APIError'; class InvalidConfiguration extends APIError { - constructor(message, results?) { + constructor(message: string, results: any) { super(message, httpStatus.INTERNAL_SERVER_ERROR, results); } } diff --git a/src/errors/InvalidSchema.ts b/src/errors/InvalidSchema.ts index e9328ec9f8..a17063bd33 100644 --- a/src/errors/InvalidSchema.ts +++ b/src/errors/InvalidSchema.ts @@ -2,7 +2,7 @@ import httpStatus from 'http-status'; import APIError from './APIError'; class InvalidSchema extends APIError { - constructor(message, results) { + constructor(message: string, results: any) { super(message, httpStatus.INTERNAL_SERVER_ERROR, results); } } diff --git a/src/errors/MissingFieldInputOptions.ts b/src/errors/MissingFieldInputOptions.ts index ec22f55a0a..f28473b4a0 100644 --- a/src/errors/MissingFieldInputOptions.ts +++ b/src/errors/MissingFieldInputOptions.ts @@ -1,7 +1,8 @@ +import { Field } from '../fields/config/types'; import APIError from './APIError'; class MissingFieldInputOptions extends APIError { - constructor(field) { + constructor(field: Field) { super(`Field ${field.label} is missing options.`); } } diff --git a/src/errors/MissingFieldType.ts b/src/errors/MissingFieldType.ts index 5593faae6c..ee6c7b2faa 100644 --- a/src/errors/MissingFieldType.ts +++ b/src/errors/MissingFieldType.ts @@ -1,7 +1,8 @@ +import { Field } from '../fields/config/types'; import APIError from './APIError'; class MissingFieldType extends APIError { - constructor(field) { + constructor(field: Field) { super(`Field "${field.name}" is either missing a field type or it does not match an available field type`); } } diff --git a/src/errors/MissingGlobalLabel.ts b/src/errors/MissingGlobalLabel.ts index 12836cbdf4..1e0603e23b 100644 --- a/src/errors/MissingGlobalLabel.ts +++ b/src/errors/MissingGlobalLabel.ts @@ -1,7 +1,8 @@ +import { Config } from '../config/types'; import APIError from './APIError'; class MissingGlobalLabel extends APIError { - constructor(config) { + constructor(config: Config) { super(`${config.globals} object is missing label`); } } diff --git a/src/errors/ValidationError.ts b/src/errors/ValidationError.ts index 3c16173c05..3977decf11 100644 --- a/src/errors/ValidationError.ts +++ b/src/errors/ValidationError.ts @@ -2,7 +2,7 @@ import httpStatus from 'http-status'; import APIError from './APIError'; class ValidationError extends APIError { - constructor(results) { + constructor(results: any[]) { super(`Bad request with ${results.length} errors`, httpStatus.BAD_REQUEST, results); } }