diff --git a/src/common/entities/Error.ts b/src/common/entities/Error.ts index 7f2fe0c4..38c8dc43 100644 --- a/src/common/entities/Error.ts +++ b/src/common/entities/Error.ts @@ -33,10 +33,12 @@ export class ErrorDTO { constructor(public code: ErrorCodes, public message?: string, public details?: any, req?: Request) { this.detailsStr = (this.details ? this.details.toString() : '') || ErrorCodes[code]; - this.request = { - method: req.method, - url: req.url - }; + if (req) { + this.request = { + method: req.method, + url: req.url + }; + } } toString(): string {