diff options
author | crupest <crupest@outlook.com> | 2022-04-25 19:30:17 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-04-25 19:30:17 +0800 |
commit | 45da78affc79ac668e3d5ce183d5c8d1c0ec3d17 (patch) | |
tree | 9e95ffd0610b6a34c3865fa8e16aede5af1769f9 /FrontEnd/src/http | |
parent | b68cf95386dbb0d58ead1cf5ca7478592b54f0b9 (diff) | |
download | timeline-45da78affc79ac668e3d5ce183d5c8d1c0ec3d17.tar.gz timeline-45da78affc79ac668e3d5ce183d5c8d1c0ec3d17.tar.bz2 timeline-45da78affc79ac668e3d5ce183d5c8d1c0ec3d17.zip |
...
Diffstat (limited to 'FrontEnd/src/http')
-rw-r--r-- | FrontEnd/src/http/timeline.ts | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/FrontEnd/src/http/timeline.ts b/FrontEnd/src/http/timeline.ts index e95d52a8..37a9ebc9 100644 --- a/FrontEnd/src/http/timeline.ts +++ b/FrontEnd/src/http/timeline.ts @@ -6,7 +6,6 @@ import { axios, apiBaseUrl, extractResponseData, - convertToIfStatusCodeIs, getHttpToken, Page, } from "./common"; @@ -186,8 +185,14 @@ export class HttpTimelineClient implements IHttpTimelineClient { postTimeline(req: HttpTimelinePostRequest): Promise<HttpTimelineInfo> { return axios .post<HttpTimelineInfo>(`${apiBaseUrl}/v2/timelines`, req) - .then(extractResponseData) - .catch(convertToIfStatusCodeIs(422, HttpTimelineNameConflictError)); + .then(extractResponseData, (error: AxiosError) => { + const statusCode = error.response?.status; + if (statusCode === 422) { + throw new HttpTimelineNameConflictError(error); + } else { + throw error; + } + }); } patchTimeline( |