diff options
Diffstat (limited to 'client/src/app/shared/rest')
-rw-r--r-- | client/src/app/shared/rest/rest-extractor.service.ts | 18 |
1 files changed, 14 insertions, 4 deletions
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 { | |||
40 | handleError (err: HttpErrorResponse) { | 40 | handleError (err: HttpErrorResponse) { |
41 | let errorMessage | 41 | let errorMessage |
42 | 42 | ||
43 | console.log(err) | ||
44 | |||
43 | if (err.error instanceof Error) { | 45 | if (err.error instanceof Error) { |
44 | // A client-side or network error occurred. Handle it accordingly. | 46 | // A client-side or network error occurred. Handle it accordingly. |
45 | errorMessage = err.error.message | 47 | errorMessage = err.error.message |
46 | console.error('An error occurred:', errorMessage) | 48 | console.error('An error occurred:', errorMessage) |
47 | } else if (err.status !== undefined) { | 49 | } else if (err.status !== undefined) { |
48 | // The backend returned an unsuccessful response code. | 50 | const body = err.error |
49 | // The response body may contain clues as to what went wrong, | 51 | errorMessage = body.error |
50 | errorMessage = err.error | ||
51 | console.error(`Backend returned code ${err.status}, body was: ${errorMessage}`) | 52 | console.error(`Backend returned code ${err.status}, body was: ${errorMessage}`) |
52 | } else { | 53 | } else { |
53 | errorMessage = err | 54 | errorMessage = err |
54 | } | 55 | } |
55 | 56 | ||
56 | return Observable.throw(errorMessage) | 57 | const errorObj = { |
58 | message: errorMessage, | ||
59 | status: undefined | ||
60 | } | ||
61 | |||
62 | if (err.status) { | ||
63 | errorObj.status = err.status | ||
64 | } | ||
65 | |||
66 | return Observable.throw(errorObj) | ||
57 | } | 67 | } |
58 | } | 68 | } |