@sendelius/vue 0.2.7 → 0.2.9
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/dist/core/errors.d.ts +9 -1
- package/dist/sendelius-vue.js +11 -5
- package/package.json +1 -1
package/dist/core/errors.d.ts
CHANGED
package/dist/sendelius-vue.js
CHANGED
|
@@ -42,9 +42,13 @@ var ae = Object.defineProperty, oe = Object.getOwnPropertyDescriptor, se = Objec
|
|
|
42
42
|
if (!he) throw Error("@sendelius/vue: initApi() должен быть запущен до getClient().");
|
|
43
43
|
return he;
|
|
44
44
|
}, ve = class extends Error {
|
|
45
|
-
constructor(e) {
|
|
46
|
-
let t =
|
|
47
|
-
|
|
45
|
+
constructor({ status: e = null, data: t = null } = {}) {
|
|
46
|
+
let n = t?.error, r = {
|
|
47
|
+
code: n?.code ?? "UNKNOWN_ERROR",
|
|
48
|
+
message: n?.message ?? "неизвестная ошибка",
|
|
49
|
+
field: n?.field ?? null
|
|
50
|
+
};
|
|
51
|
+
super(r.message), this.name = "ApiError", this.status = e, this.data = t, this.error = r, this.field = r.field;
|
|
48
52
|
}
|
|
49
53
|
};
|
|
50
54
|
// src/core/requests.js
|
|
@@ -74,11 +78,13 @@ async function we(e, t, n = {}, r = {}) {
|
|
|
74
78
|
...r
|
|
75
79
|
}) : await _e()[e](t, n, r);
|
|
76
80
|
} catch (e) {
|
|
77
|
-
throw e.response?.status === 401 && me().onUnauthorized?.(), new ve(
|
|
81
|
+
throw e.response?.status === 401 && me().onUnauthorized?.(), new ve({
|
|
82
|
+
status: e.response?.status ?? null,
|
|
83
|
+
data: e.response?.data ?? null
|
|
84
|
+
});
|
|
78
85
|
}
|
|
79
86
|
let a = i.data;
|
|
80
87
|
if (a?.status !== "success") throw new ve({
|
|
81
|
-
message: a?.error || a?.message || "неизвестная ошибка",
|
|
82
88
|
status: i.status,
|
|
83
89
|
data: a
|
|
84
90
|
});
|
package/package.json
CHANGED