diff --git a/src/cli/models/response.ts b/src/cli/models/response.ts index 8e3dc5819f..d3a858ac47 100644 --- a/src/cli/models/response.ts +++ b/src/cli/models/response.ts @@ -7,7 +7,8 @@ export class Response { if (typeof (error) === 'string') { res.message = error; } else { - res.message = error.message != null ? error.message : error.toString(); + res.message = error.message != null ? error.message : + error.toString() === '[object Object]' ? JSON.stringify(error) : error.toString(); } res.data = data; return res; diff --git a/src/services/api.service.ts b/src/services/api.service.ts index a9ce9942b3..5f3aefe35b 100644 --- a/src/services/api.service.ts +++ b/src/services/api.service.ts @@ -1282,6 +1282,8 @@ export class ApiService implements ApiServiceAbstraction { let responseJson: any = null; if (this.isJsonResponse(response)) { responseJson = await response.json(); + } else if (this.isTextResponse(response)) { + responseJson = {Message: await response.text()}; } return new ErrorResponse(responseJson, response.status, tokenError); @@ -1357,4 +1359,9 @@ export class ApiService implements ApiServiceAbstraction { const typeHeader = response.headers.get('content-type'); return typeHeader != null && typeHeader.indexOf('application/json') > -1; } + + private isTextResponse(response: Response): boolean { + const typeHeader = response.headers.get('content-type'); + return typeHeader != null && typeHeader.indexOf('text') > -1; + } }