fix: error class
This commit is contained in:
		
							parent
							
								
									d746b36ba6
								
							
						
					
					
						commit
						853d9fd0fa
					
				
					 1 changed files with 3 additions and 10 deletions
				
			
		|  | @ -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<Document[]>; | ||||
|     addList: (content_list: DocumentBody[]) => Promise<number[]>; | ||||
|  | @ -25,6 +17,7 @@ export class ClientDocumentAccessor implements DocumentAccessor{ | |||
|     }; | ||||
|     async findList(option?: QueryListOption | undefined): Promise<Document[]>{ | ||||
|         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; | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 monoid
						monoid