vona-core 5.1.35 → 5.1.37
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/index.js +15 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/bean/resource/error/errorClass.d.ts +2 -0
- package/dist/lib/bean/resource/error/errorClass.d.ts.map +1 -1
- package/dist/lib/bean/resource/error/errorObject.d.ts +1 -0
- package/dist/lib/bean/resource/error/errorObject.d.ts.map +1 -1
- package/dist/lib/bean/type.d.ts +5 -1
- package/dist/lib/bean/type.d.ts.map +1 -1
- package/dist/types/interface/module.d.ts +6 -1
- package/dist/types/interface/module.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/lib/bean/resource/error/errorClass.ts +21 -4
- package/src/lib/bean/resource/error/errorObject.ts +1 -0
- package/src/lib/bean/type.ts +3 -1
- package/src/types/interface/module.ts +6 -1
package/dist/index.js
CHANGED
|
@@ -1744,7 +1744,7 @@ class ErrorClass extends BeanSimple {
|
|
|
1744
1744
|
// code/message,args
|
|
1745
1745
|
fail(module, code, ...args) {
|
|
1746
1746
|
const body = this.parseFail(module, code, ...args);
|
|
1747
|
-
this.ctx.response.status =
|
|
1747
|
+
this.ctx.response.status = body.status;
|
|
1748
1748
|
this.ctx.response.type = 'application/json';
|
|
1749
1749
|
this.ctx.response.body = {
|
|
1750
1750
|
code: body.code,
|
|
@@ -1758,7 +1758,7 @@ class ErrorClass extends BeanSimple {
|
|
|
1758
1758
|
const err = new Error();
|
|
1759
1759
|
err.code = body.code;
|
|
1760
1760
|
err.message = body.message;
|
|
1761
|
-
err.status =
|
|
1761
|
+
err.status = body.status;
|
|
1762
1762
|
throw err;
|
|
1763
1763
|
}
|
|
1764
1764
|
|
|
@@ -1784,9 +1784,16 @@ class ErrorClass extends BeanSimple {
|
|
|
1784
1784
|
|
|
1785
1785
|
// convert from enum
|
|
1786
1786
|
let text;
|
|
1787
|
+
let status;
|
|
1787
1788
|
if (ebError && code && typeof code === 'string') {
|
|
1788
1789
|
text = code;
|
|
1789
|
-
|
|
1790
|
+
const declaration = ebError[code];
|
|
1791
|
+
if (__isErrorDescriptor(declaration)) {
|
|
1792
|
+
code = declaration.code;
|
|
1793
|
+
status = declaration.status;
|
|
1794
|
+
} else {
|
|
1795
|
+
code = declaration;
|
|
1796
|
+
}
|
|
1790
1797
|
}
|
|
1791
1798
|
if (code === undefined || code === null || code === '') {
|
|
1792
1799
|
code = codeDefault;
|
|
@@ -1798,12 +1805,17 @@ class ErrorClass extends BeanSimple {
|
|
|
1798
1805
|
message = this.app.meta.locale.getText(false, module, undefined, text || code, ...args);
|
|
1799
1806
|
}
|
|
1800
1807
|
code = __combineErrorCode(module, code);
|
|
1808
|
+
status ??= __calcStatus(code);
|
|
1801
1809
|
return {
|
|
1802
1810
|
code,
|
|
1811
|
+
status,
|
|
1803
1812
|
message
|
|
1804
1813
|
};
|
|
1805
1814
|
}
|
|
1806
1815
|
}
|
|
1816
|
+
function __isErrorDescriptor(value) {
|
|
1817
|
+
return value && typeof value === 'object' && typeof value.code === 'number' && typeof value.status === 'number';
|
|
1818
|
+
}
|
|
1807
1819
|
function __combineErrorCode(module, code) {
|
|
1808
1820
|
if (typeof code !== 'number' || code <= 1000) return code;
|
|
1809
1821
|
return module ? `${module}:${code}` : code;
|