From 05159facce5fea5014551f798a690e2ed6610ece Mon Sep 17 00:00:00 2001 From: Muhammed Irfan K Date: Sat, 2 Jan 2021 10:49:40 +0530 Subject: [PATCH] Fixed spacing --- src/exceptions/configuration.exception.ts | 1 - src/exceptions/exception.ts | 1 - src/middlewares/error-handler.middleware.ts | 4 ++-- src/modules/configuration.module.ts | 1 - 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/exceptions/configuration.exception.ts b/src/exceptions/configuration.exception.ts index 67598bb..1efe1a7 100644 --- a/src/exceptions/configuration.exception.ts +++ b/src/exceptions/configuration.exception.ts @@ -6,7 +6,6 @@ import { Exception } from './exception'; */ export class ConfigurationException extends Exception { - constructor(description) { super('ConfigurationException', description, false); } diff --git a/src/exceptions/exception.ts b/src/exceptions/exception.ts index 39df809..dfb729f 100644 --- a/src/exceptions/exception.ts +++ b/src/exceptions/exception.ts @@ -3,7 +3,6 @@ */ export abstract class Exception extends Error { - public readonly name: string; public readonly isOperational: boolean | undefined; public readonly description: string; diff --git a/src/middlewares/error-handler.middleware.ts b/src/middlewares/error-handler.middleware.ts index ebf418f..f35b459 100644 --- a/src/middlewares/error-handler.middleware.ts +++ b/src/middlewares/error-handler.middleware.ts @@ -6,9 +6,7 @@ import { createLogger, transports, format } from "winston"; */ class ErrorHandlerMiddleware { - public async handleError(error: Exception): Promise { - // Build a custom logger to handle configuration error as the logger transports will be added only after the validating the configration. Without this winston will throw `Attempt to write logs with no transports`. if(error instanceof ConfigurationException) { const logger = createLogger( @@ -27,6 +25,7 @@ class ErrorHandlerMiddleware { ], } ); + logger.log("error", error.message); } @@ -37,4 +36,5 @@ class ErrorHandlerMiddleware { } } } + export const ErrorHandler = new ErrorHandlerMiddleware(); \ No newline at end of file diff --git a/src/modules/configuration.module.ts b/src/modules/configuration.module.ts index 64ff5bd..1d1132d 100644 --- a/src/modules/configuration.module.ts +++ b/src/modules/configuration.module.ts @@ -11,7 +11,6 @@ import { ConfigurationException } from "@exceptions"; */ export const ConfigurationModule: MicroframeworkLoader = (frameworkSettings: MicroframeworkSettings | undefined) => { - if (frameworkSettings) { // Build Yup schema from the provided json schema. const yupSchema = buildYup(jsonSchema, {});