From bfb3a98fac582f104c6d9b8b7242ea2cbb650b91 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 14 Sep 2017 17:06:31 +0200 Subject: Remove ng2 file upload module Unmaintained and we don't need it anymore with httpclient --- client/src/app/shared/rest/rest-extractor.service.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'client/src/app/shared/rest') diff --git a/client/src/app/shared/rest/rest-extractor.service.ts b/client/src/app/shared/rest/rest-extractor.service.ts index 32dad5c73..1f6222da8 100644 --- a/client/src/app/shared/rest/rest-extractor.service.ts +++ b/client/src/app/shared/rest/rest-extractor.service.ts @@ -40,19 +40,29 @@ export class RestExtractor { handleError (err: HttpErrorResponse) { let errorMessage + console.log(err) + if (err.error instanceof Error) { // A client-side or network error occurred. Handle it accordingly. errorMessage = err.error.message console.error('An error occurred:', errorMessage) } else if (err.status !== undefined) { - // The backend returned an unsuccessful response code. - // The response body may contain clues as to what went wrong, - errorMessage = err.error + const body = err.error + errorMessage = body.error console.error(`Backend returned code ${err.status}, body was: ${errorMessage}`) } else { errorMessage = err } - return Observable.throw(errorMessage) + const errorObj = { + message: errorMessage, + status: undefined + } + + if (err.status) { + errorObj.status = err.status + } + + return Observable.throw(errorObj) } } -- cgit v1.2.3