@knime/hub-features 1.15.3 → 1.15.4

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,13 @@
1
1
  # @knime/hub-features
2
2
 
3
+ ## 1.15.4
4
+
5
+ ### Patch Changes
6
+
7
+ - e44c108: fix rfcErrors parser and return undefined on error
8
+ - Updated dependencies [e44c108]
9
+ - @knime/components@1.41.8
10
+
3
11
  ## 1.15.3
4
12
 
5
13
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knime/hub-features",
3
- "version": "1.15.3",
3
+ "version": "1.15.4",
4
4
  "description": "Vue components & composables for shared hub features",
5
5
  "repository": {
6
6
  "type": "git",
@@ -36,7 +36,7 @@
36
36
  "lodash-es": "4.17.21",
37
37
  "ofetch": "^1.4.1",
38
38
  "typescript": "^5.8.3",
39
- "@knime/components": "1.41.7",
39
+ "@knime/components": "1.41.8",
40
40
  "@knime/styles": "1.14.3",
41
41
  "@knime/utils": "1.7.1"
42
42
  },
@@ -1,4 +1,4 @@
1
- import { FetchError, type FetchOptions } from "ofetch";
1
+ import { type FetchOptions } from "ofetch";
2
2
 
3
3
  import { type HubAvatarData, rfcErrors } from "@knime/hub-features";
4
4
  import { VERSION_DEFAULT_LIMIT } from "@knime/hub-features/versions";
@@ -37,11 +37,7 @@ export const useVersionsApi = ({
37
37
 
38
38
  return await $ofetch(path, { ...defaults, ...fetchOptions });
39
39
  } catch (error) {
40
- if (error instanceof FetchError) {
41
- throw rfcErrors.tryParse(error);
42
- }
43
-
44
- throw error;
40
+ throw rfcErrors.tryParse(error) ?? error;
45
41
  }
46
42
  };
47
43
 
@@ -35,21 +35,28 @@ const toToast = ({
35
35
  };
36
36
 
37
37
  /**
38
- * Try to parse an ofetch's `FetchError` to an `RFCError`. When parsing is not possible
39
- * it returns the same `FetchError` given unchanged.
38
+ * Parse an ofetch's `FetchError` to an `RFCError`.
39
+ * When parsing is not possible it returns undefined.
40
40
  */
41
- const tryParse = (error: FetchError): RFCError | FetchError => {
41
+ const tryParse = (error: unknown): RFCError | undefined => {
42
+ if (!(error instanceof FetchError)) {
43
+ return undefined;
44
+ }
45
+
42
46
  if (!error.response) {
43
- return error;
47
+ return undefined;
44
48
  }
45
49
 
46
50
  const responseDate = error.response.headers.get("date")
47
51
  ? new Date(error.response.headers.get("date")!)
48
52
  : undefined;
49
53
 
54
+ const title =
55
+ typeof error.data === "string" ? error.data : error.data?.title ?? "";
56
+
50
57
  const rfcErrorData: RFCErrorData = {
51
- title: error.data.title as string,
52
- details: error.data.details as string[] | undefined,
58
+ title: title as string,
59
+ details: error.data?.details as string[] | undefined,
53
60
  status: error.statusCode as number,
54
61
  date: responseDate,
55
62
  requestId: error.response.headers.get("x-request-id") ?? undefined,
@@ -284,10 +284,7 @@ export const useDownloadArtifact = (
284
284
  } catch (error: unknown) {
285
285
  // here only errors thrown by the initial requests are caught;
286
286
  // errors occurring while polling will be handled in pollDownloadItem
287
- if (error instanceof FetchError) {
288
- throw rfcErrors.tryParse(error);
289
- }
290
- throw error;
287
+ throw rfcErrors.tryParse(error) ?? error;
291
288
  }
292
289
  };
293
290
 
@@ -287,11 +287,7 @@ export const useFileUpload = (options: UseFileUploadOptions = {}) => {
287
287
 
288
288
  useUploadManagerResult.start(parentId, uploadPayload);
289
289
  } catch (error) {
290
- if (error instanceof FetchError) {
291
- throw rfcErrors.tryParse(error);
292
- }
293
-
294
- throw error;
290
+ throw rfcErrors.tryParse(error) ?? error;
295
291
  } finally {
296
292
  // errors can only be thrown in the prepareUpload call, useUploadManagerResult.start does its own error handling
297
293
  prepareQueueSize.value -= enqueableFiles.length;