import { Response } from "node-fetch"; export interface Meta { status: number; errorCode?: number; errorMessage?: string; } export interface BaseResponse { meta: Meta; data: T; } export class AgcError extends Error { response: Response; parsedResponse?: BaseResponse; constructor(response: Response, message?: string) { super(message); this.response = response; this.parsedResponse = undefined; } async parse() { this.parsedResponse = await this.response.json(); } async tryParse() { try { this.parse(); } catch { // 何もしない } } }