From 853d9fd0fa129b23750fee469e76d6db4633ff9e Mon Sep 17 00:00:00 2001 From: monoid Date: Wed, 29 Jun 2022 17:02:40 +0900 Subject: [PATCH] fix: error class --- src/client/accessor/document.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/client/accessor/document.ts b/src/client/accessor/document.ts index f176160..2fcb9ad 100644 --- a/src/client/accessor/document.ts +++ b/src/client/accessor/document.ts @@ -4,16 +4,8 @@ const baseurl = "/api/doc"; export * from "../../model/doc"; -export class FetchFailError implements Error{ - name: string; - message: string; - stack?: string; - constructor(message:string,stack?:string){ - this.name = "Fetch Fail"; - this.message = message; - this.stack = stack; - } -} +export class FetchFailError extends Error{} + export class ClientDocumentAccessor implements DocumentAccessor{ search: (search_word: string) => Promise; addList: (content_list: DocumentBody[]) => Promise; @@ -25,6 +17,7 @@ export class ClientDocumentAccessor implements DocumentAccessor{ }; async findList(option?: QueryListOption | undefined): Promise{ let res = await fetch(`${baseurl}/search?${option !== undefined ? toQueryString(option) : ""}`); + if(res.status == 401) throw new FetchFailError("Unauthorized") if(res.status !== 200) throw new FetchFailError("findList Failed"); let ret = await res.json(); return ret;