@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
@@ -1,5 +1,11 @@
1
1
  # @hashrytech/quick-components-kit
2
2
 
3
+ ## 0.19.12
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: Adjusting 2 error handlers so that 1 returns problem details and the other returns the default error
8
+
3
9
  ## 0.19.11
4
10
 
5
11
  ### Patch Changes
@@ -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: Error) => Promise<void> | void;
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
- const err = error instanceof Error ? error : new Error(String(error));
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.handleError(errorObj);
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 {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/hashrytech/quick-components-kit.git"
7
7
  },
8
- "version": "0.19.11",
8
+ "version": "0.19.12",
9
9
  "license": "MIT",
10
10
  "author": "Hashry Tech",
11
11
  "files": [