@globalbrain/sefirot 4.43.2 → 4.43.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/lib/composables/Error.ts +4 -2
- package/lib/support/Http.ts +10 -0
- package/package.json +1 -1
package/lib/composables/Error.ts
CHANGED
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
toValue
|
|
28
28
|
} from 'vue'
|
|
29
29
|
import { useError } from '../stores/Error'
|
|
30
|
+
import { getHttpStatusCode } from '../support/Http'
|
|
30
31
|
|
|
31
32
|
export interface User {
|
|
32
33
|
id?: string | number
|
|
@@ -214,9 +215,10 @@ export function useErrorHandler({
|
|
|
214
215
|
userValue = null
|
|
215
216
|
}
|
|
216
217
|
|
|
217
|
-
const
|
|
218
|
+
const statusCode = getHttpStatusCode(e)
|
|
219
|
+
if (!statusCode || statusCode < 400 || statusCode >= 500) {
|
|
220
|
+
//
|
|
218
221
|
|
|
219
|
-
if (![403, 404].includes(status)) {
|
|
220
222
|
const $ = instance && instance.$
|
|
221
223
|
const metadata = $ && {
|
|
222
224
|
componentName: formatComponentName($),
|
package/lib/support/Http.ts
CHANGED
|
@@ -40,3 +40,13 @@ export function objectToFormData(
|
|
|
40
40
|
|
|
41
41
|
return fd
|
|
42
42
|
}
|
|
43
|
+
|
|
44
|
+
export function getHttpStatusCode(error: any): number | undefined {
|
|
45
|
+
const sources = [error, error?.cause, error?.details, error?.error]
|
|
46
|
+
.filter((s) => s && typeof s === 'object')
|
|
47
|
+
|
|
48
|
+
return sources
|
|
49
|
+
.flatMap((s) => [s.status, s.statusCode, s.response?.status, s.response?.statusCode, s.code])
|
|
50
|
+
.map(Number)
|
|
51
|
+
.find((n) => Number.isInteger(n) && n >= 100 && n <= 599)
|
|
52
|
+
}
|