@opensdks/runtime
Advanced tools
Comparing version 0.0.17 to 0.0.18
@@ -9,3 +9,8 @@ "use strict"; | ||
constructor({ method, error, response: r, }) { | ||
super(`[${r.status} ${r.statusText}] ${method.toUpperCase()} ${r.url}`); | ||
super([ | ||
`[${r.status} ${r.statusText}] ${method.toUpperCase()} ${r.url}`, | ||
safeJsonStringify(error), | ||
] | ||
.filter((l) => !!l) | ||
.join('\n')); | ||
this.name = 'HTTPError'; | ||
@@ -19,2 +24,13 @@ this.method = method; | ||
exports.HTTPError = HTTPError; | ||
function safeJsonStringify(value) { | ||
try { | ||
if (value == null) { | ||
return null; | ||
} | ||
return JSON.stringify(value); | ||
} | ||
catch { | ||
return `Not JSON: ${value}`; | ||
} | ||
} | ||
//# sourceMappingURL=HTTPError.js.map |
@@ -6,3 +6,8 @@ export class HTTPError extends Error { | ||
constructor({ method, error, response: r, }) { | ||
super(`[${r.status} ${r.statusText}] ${method.toUpperCase()} ${r.url}`); | ||
super([ | ||
`[${r.status} ${r.statusText}] ${method.toUpperCase()} ${r.url}`, | ||
safeJsonStringify(error), | ||
] | ||
.filter((l) => !!l) | ||
.join('\n')); | ||
this.name = 'HTTPError'; | ||
@@ -15,2 +20,13 @@ this.method = method; | ||
} | ||
function safeJsonStringify(value) { | ||
try { | ||
if (value == null) { | ||
return null; | ||
} | ||
return JSON.stringify(value); | ||
} | ||
catch { | ||
return `Not JSON: ${value}`; | ||
} | ||
} | ||
//# sourceMappingURL=HTTPError.js.map |
@@ -19,3 +19,10 @@ import type {FetchResponse} from 'openapi-fetch' | ||
}: Extract<FetchResponse<T>, {error: unknown}> & {method: HTTPMethod}) { | ||
super(`[${r.status} ${r.statusText}] ${method.toUpperCase()} ${r.url}`) | ||
super( | ||
[ | ||
`[${r.status} ${r.statusText}] ${method.toUpperCase()} ${r.url}`, | ||
safeJsonStringify(error), | ||
] | ||
.filter((l) => !!l) | ||
.join('\n'), | ||
) | ||
this.method = method | ||
@@ -27,1 +34,12 @@ this.error = error | ||
} | ||
function safeJsonStringify(value: unknown) { | ||
try { | ||
if (value == null) { | ||
return null | ||
} | ||
return JSON.stringify(value) | ||
} catch { | ||
return `Not JSON: ${value}` | ||
} | ||
} |
@@ -41,3 +41,4 @@ import type {oas30, oas31} from 'openapi3-ts' | ||
}> & { | ||
types: T | ||
/** Only exists at compile time used for type inference */ | ||
readonly types: T | ||
createClient?: ( | ||
@@ -44,0 +45,0 @@ ctx: { |
{ | ||
"name": "@opensdks/runtime", | ||
"version": "0.0.17", | ||
"version": "0.0.18", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "exports": { |
@@ -27,3 +27,4 @@ import type { oas30, oas31 } from 'openapi3-ts'; | ||
}> & { | ||
types: T; | ||
/** Only exists at compile time used for type inference */ | ||
readonly types: T; | ||
createClient?: (ctx: { | ||
@@ -30,0 +31,0 @@ createClient: <TPaths extends {} = T['oas']['paths']>(opts: ClientOptions) => OpenAPIClient<TPaths>; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
46469
602