cloud-error
Version:
node micservice custome error
36 lines • 1.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
class CloudError extends Error {
constructor(code, msg, http_status = 400) {
super(msg);
this.code = code;
this.msg = msg;
this.http_status = http_status;
}
toJSON() {
return {
code: this.code,
msg: this.msg,
};
}
}
exports.CloudError = CloudError;
class E {
static INVALID_PARAM(params) {
return new CloudError(400, `参数${params}不合法`, 400);
}
static SYSTEM_ERROR() {
return new CloudError(500, '系统内部错误,请稍后重试', 500);
}
static PERMISSION_DENY(params) {
return new CloudError(403, `您没有权限访问${params},请联系管理员`, 403);
}
static NEED_LOGIN() {
return new CloudError(401, "您还没有登录", 401);
}
static CUSTOMER_ERROR(code, msg, httpCode) {
return new CloudError(code, msg, httpCode);
}
}
exports.default = E;
//# sourceMappingURL=index.js.map