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;