@data-fair/lib-vue 1.13.2 → 1.13.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/async-action.js +2 -3
- package/package.json +1 -1
- package/ui-notif.d.ts +4 -0
- package/ui-notif.js +11 -1
package/async-action.js
CHANGED
|
@@ -21,9 +21,8 @@ export function asyncAction (fn, options) {
|
|
|
21
21
|
}
|
|
22
22
|
return result
|
|
23
23
|
} catch (err) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const errorNotif = getFullNotif({ msg: options?.error ?? '', error: errorMsg })
|
|
24
|
+
error.value = getErrorMsg(err)
|
|
25
|
+
const errorNotif = getFullNotif({ msg: options?.error ?? '', error: err })
|
|
27
26
|
notif.value = errorNotif
|
|
28
27
|
if (options?.catch !== 'error' && options?.catch !== 'all') {
|
|
29
28
|
sendUiNotif(errorNotif)
|
package/package.json
CHANGED
package/ui-notif.d.ts
CHANGED
|
@@ -16,7 +16,9 @@ interface UiNotifError {
|
|
|
16
16
|
msg: string;
|
|
17
17
|
error: any;
|
|
18
18
|
errorMsg: string;
|
|
19
|
+
clientError?: boolean;
|
|
19
20
|
}
|
|
21
|
+
export declare function getErrorCode(error: any): number;
|
|
20
22
|
export declare function getErrorMsg(error: any): string;
|
|
21
23
|
export declare function getFullNotif(notif: PartialUiNotif, defaultType?: UiNotifBase['type']): UiNotif;
|
|
22
24
|
export declare const getUiNotif: () => {
|
|
@@ -28,6 +30,7 @@ export declare const getUiNotif: () => {
|
|
|
28
30
|
msg: string;
|
|
29
31
|
error: any;
|
|
30
32
|
errorMsg: string;
|
|
33
|
+
clientError?: boolean | undefined;
|
|
31
34
|
} | null, UiNotif | {
|
|
32
35
|
type?: ("default" | "info" | "success" | "warning") | undefined;
|
|
33
36
|
msg: string;
|
|
@@ -36,6 +39,7 @@ export declare const getUiNotif: () => {
|
|
|
36
39
|
msg: string;
|
|
37
40
|
error: any;
|
|
38
41
|
errorMsg: string;
|
|
42
|
+
clientError?: boolean | undefined;
|
|
39
43
|
} | null>;
|
|
40
44
|
sendUiNotif: (partialNotif: PartialUiNotif) => void;
|
|
41
45
|
};
|
package/ui-notif.js
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
// or can be displayed locally by @data-fair/lib-vuetify/ui-notif.vue
|
|
4
4
|
import { ref, inject } from 'vue'
|
|
5
5
|
import inIframe from '@data-fair/lib-utils/in-iframe.js'
|
|
6
|
+
export function getErrorCode (error) {
|
|
7
|
+
if (typeof error === 'string') { return 500 }
|
|
8
|
+
if (typeof error.statusCode === 'number') { return error.statusCode }
|
|
9
|
+
if (typeof error.response?.statusCode === 'number') { return error.response?.statusCode }
|
|
10
|
+
if (typeof error.code === 'number') { return error.code }
|
|
11
|
+
if (typeof error.response?.code === 'number') { return error.response?.code }
|
|
12
|
+
return 500
|
|
13
|
+
}
|
|
6
14
|
export function getErrorMsg (error) {
|
|
7
15
|
if (typeof error === 'string') { return error }
|
|
8
16
|
if (error.data && typeof error.data === 'string') { return error.data }
|
|
@@ -15,10 +23,12 @@ export function getErrorMsg (error) {
|
|
|
15
23
|
export function getFullNotif (notif, defaultType = 'default') {
|
|
16
24
|
if (typeof notif === 'string') { return { msg: notif, type: defaultType } }
|
|
17
25
|
if (notif.error) {
|
|
26
|
+
const code = getErrorCode(notif.error)
|
|
18
27
|
return {
|
|
19
28
|
...notif,
|
|
20
29
|
type: 'error',
|
|
21
|
-
errorMsg: getErrorMsg(notif.error)
|
|
30
|
+
errorMsg: getErrorMsg(notif.error),
|
|
31
|
+
clientError: code < 500
|
|
22
32
|
}
|
|
23
33
|
}
|
|
24
34
|
return {
|