X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fcore%2Frest%2Frest-extractor.service.ts;h=b8a95cca63d1a6e22c9c4f965ab3a3c8e8618f67;hb=ab398a05e9ffaacb8fc713bb2ba9717ac463b34c;hp=4b8c1e1555579567de687f068487568185eb6e88;hpb=dc5bb5cea5bf7e906caa6d9c5468e6de36e605de;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/core/rest/rest-extractor.service.ts b/client/src/app/core/rest/rest-extractor.service.ts index 4b8c1e155..b8a95cca6 100644 --- a/client/src/app/core/rest/rest-extractor.service.ts +++ b/client/src/app/core/rest/rest-extractor.service.ts @@ -3,6 +3,7 @@ import { Injectable } from '@angular/core' import { Router } from '@angular/router' import { dateToHuman } from '@app/helpers' import { ResultList } from '@shared/models' +import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' @Injectable() export class RestExtractor { @@ -57,9 +58,9 @@ export class RestExtractor { errorMessage = errorsArray.join('. ') } else if (err.error && err.error.error) { errorMessage = err.error.error - } else if (err.status === 413) { + } else if (err.status === HttpStatusCode.PAYLOAD_TOO_LARGE_413) { errorMessage = $localize`Media is too large for the server. Please contact you administrator if you want to increase the limit size.` - } else if (err.status === 429) { + } else if (err.status === HttpStatusCode.TOO_MANY_REQUESTS_429) { const secondsLeft = err.headers.get('retry-after') if (secondsLeft) { const minutesLeft = Math.floor(parseInt(secondsLeft, 10) / 60) @@ -67,7 +68,7 @@ export class RestExtractor { } else { errorMessage = $localize`Too many attempts, please try again later.` } - } else if (err.status === 500) { + } else if (err.status === HttpStatusCode.INTERNAL_SERVER_ERROR_500) { errorMessage = $localize`Server error. Please retry later.` } @@ -92,10 +93,10 @@ export class RestExtractor { return observableThrowError(errorObj) } - redirectTo404IfNotFound (obj: { status: number }, status = [ 404 ]) { + redirectTo404IfNotFound (obj: { status: number }, type: 'video' | 'other', status = [ HttpStatusCode.NOT_FOUND_404 ]) { if (obj && obj.status && status.indexOf(obj.status) !== -1) { // Do not use redirectService to avoid circular dependencies - this.router.navigate([ '/404' ], { skipLocationChange: true }) + this.router.navigate([ '/404' ], { state: { type, obj }, skipLocationChange: true }) } return observableThrowError(obj)