diff --git a/src/client/accessor/contents.ts b/src/client/accessor/contents.ts index f8014ea..d35353c 100644 --- a/src/client/accessor/contents.ts +++ b/src/client/accessor/contents.ts @@ -3,16 +3,27 @@ import {toQueryString} from './util'; const baseurl = "/content"; export * from "../../model/contents"; + +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 ClientContentAccessor implements ContentAccessor{ async findList(option?: QueryListOption | undefined): Promise{ let res = await fetch(`${baseurl}/search?${option !== undefined ? toQueryString(option) : ""}`); - //if(res.status !== 200); + if(res.status !== 200) throw new FetchFailError("findList Failed"); let ret = await res.json(); return ret; } async findById(id: number, tagload?: boolean | undefined): Promise{ let res = await fetch(`${baseurl}/${id}`); - if(res.status !== 200) return undefined; + if(res.status !== 200) throw new FetchFailError("findById Failed");; let ret = await res.json(); return ret; }