diff --git a/src/types/ErrorResponse.ts b/src/types/ErrorResponse.ts index 1f88c8f..d0ff0e0 100644 --- a/src/types/ErrorResponse.ts +++ b/src/types/ErrorResponse.ts @@ -2,14 +2,25 @@ export class ErrorResponse { body: ErrorBody constructor(message: string, details?: any) { + let detailsString = ''; + let raw + + try { + detailsString = JSON.stringify(details) + } catch { + raw = details + } + this.body = { message, - details + details: detailsString, + raw } } } interface ErrorBody { message: string - details: any + details: string, + raw: any }