X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=client%2Fsrc%2Fapp%2Fshared%2Frest%2Frest-extractor.service.ts;h=1f6222da82386815383fc7505107b185cbd6d8f2;hb=bfb3a98fac582f104c6d9b8b7242ea2cbb650b91;hp=32dad5c732e00e47cecf3e67710ad7df7d713388;hpb=d5050d1e097e761685fbaafe6e3d4b8b78d48356;p=github%2FChocobozzz%2FPeerTube.git 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) } }