@hashrytech/quick-components-kit 0.19.11 → 0.19.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -65,7 +65,7 @@ export declare class FetchError extends Error {
|
|
|
65
65
|
export interface FetchClientEvents {
|
|
66
66
|
onRequest?: (request: Request) => Promise<void> | void;
|
|
67
67
|
onResponse?: (response: Response) => Promise<void> | void;
|
|
68
|
-
onError?: (error:
|
|
68
|
+
onError?: (error: ProblemDetail) => Promise<void> | void;
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
71
|
* A generic REST API client.
|
|
@@ -279,14 +279,12 @@ export class FetchClient {
|
|
|
279
279
|
catch (error) {
|
|
280
280
|
if (this.debug)
|
|
281
281
|
console.debug(`Fetch Client: Error occurred while processing request to ${endpoint} with method ${method}`, error);
|
|
282
|
-
|
|
283
|
-
await this.emit('onError', err);
|
|
284
|
-
//this.events.onError?.(err);
|
|
282
|
+
await this.handleError(error);
|
|
285
283
|
const isApiError = error instanceof FetchError;
|
|
286
284
|
const status = isApiError ? error.status : 503; // Service Unavailable fallback
|
|
287
285
|
const message = error instanceof Error ? error.message : 'Unexpected error occurred';
|
|
288
286
|
const errorObj = isApiError && error.json ? error.json : getProblemDetail({ status, title: "Server fetch error", type: "/exceptions/fetch-error/", detail: message });
|
|
289
|
-
await this.
|
|
287
|
+
await this.emit('onError', errorObj);
|
|
290
288
|
//const errorObj = status != 503 ? message : getProblemDetail({status, title: "Server fetch error", type: "/exceptions/fetch-error/", detail: "Error fetching data from API", server: message });
|
|
291
289
|
this.evaluateRedirect(errorObj, status);
|
|
292
290
|
return {
|