diff options
author | crupest <crupest@outlook.com> | 2020-08-07 23:51:29 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-08-07 23:51:29 +0800 |
commit | e0051ef2330f56ff13ca57b7c01059cf4365493e (patch) | |
tree | e6a41dac9ad481fe192b58e676f927cde74207ab /Timeline/ClientApp/src/app/http/common.ts | |
parent | 639c3e4456247f070179971f0ae426431b4da467 (diff) | |
download | timeline-e0051ef2330f56ff13ca57b7c01059cf4365493e.tar.gz timeline-e0051ef2330f56ff13ca57b7c01059cf4365493e.tar.bz2 timeline-e0051ef2330f56ff13ca57b7c01059cf4365493e.zip |
...
Diffstat (limited to 'Timeline/ClientApp/src/app/http/common.ts')
-rw-r--r-- | Timeline/ClientApp/src/app/http/common.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Timeline/ClientApp/src/app/http/common.ts b/Timeline/ClientApp/src/app/http/common.ts index 3c2f2ba6..8b082d1f 100644 --- a/Timeline/ClientApp/src/app/http/common.ts +++ b/Timeline/ClientApp/src/app/http/common.ts @@ -45,6 +45,12 @@ export class HttpNetworkError extends Error { }
}
+export class HttpForbiddenError extends Error {
+ constructor(public innerError?: AxiosError) {
+ super();
+ }
+}
+
export class NotModified {}
export interface BlobWithEtag {
@@ -119,6 +125,20 @@ export function convertToNetworkError( }
}
+export function convertToForbiddenError(
+ error: AxiosError<CommonErrorResponse>
+): never {
+ if (
+ error.isAxiosError &&
+ error.response != null &&
+ (error.response.status == 403 || error.response.status == 403)
+ ) {
+ throw new HttpForbiddenError(error);
+ } else {
+ throw error;
+ }
+}
+
export function extractDataOrConvert304ToNotModified<T>(
res: AxiosResponse<T>
): T | NotModified {
|