chore: lib-server

This commit is contained in:
xiaojunnuo
2024-10-03 22:03:49 +08:00
parent a13203fb3f
commit a4e2cc54e6
101 changed files with 936 additions and 223 deletions
@@ -0,0 +1,14 @@
import { Constants } from '../constants.js';
import { BaseException } from './base-exception.js';
/**
* 授权异常
*/
export class AuthException extends BaseException {
constructor(message) {
super(
'AuthException',
Constants.res.auth.code,
message ? message : Constants.res.auth.message
);
}
}
@@ -0,0 +1,11 @@
/**
* 异常基类
*/
export class BaseException extends Error {
status: number;
constructor(name, code, message) {
super(message);
this.name = name;
this.status = code;
}
}
@@ -0,0 +1,14 @@
import { Constants } from '../constants.js';
import { BaseException } from './base-exception.js';
/**
* 通用异常
*/
export class CommonException extends BaseException {
constructor(message) {
super(
'CommonException',
Constants.res.error.code,
message ? message : Constants.res.error.message
);
}
}
@@ -0,0 +1,7 @@
export * from './auth-exception.js'
export * from './base-exception.js'
export * from './permission-exception.js'
export * from './preview-exception.js'
export * from './validation-exception.js'
export * from './vip-exception.js'
export * from './common-exception.js'
@@ -0,0 +1,14 @@
import { Constants } from '../constants.js';
import { BaseException } from './base-exception.js';
/**
* 授权异常
*/
export class PermissionException extends BaseException {
constructor(message?: string) {
super(
'PermissionException',
Constants.res.permission.code,
message ? message : Constants.res.permission.message
);
}
}
@@ -0,0 +1,14 @@
import { Constants } from '../constants.js';
import { BaseException } from './base-exception.js';
/**
* 预览模式
*/
export class PreviewException extends BaseException {
constructor(message) {
super(
'PreviewException',
Constants.res.preview.code,
message ? message : Constants.res.preview.message
);
}
}
@@ -0,0 +1,14 @@
import { Constants } from '../constants.js';
import { BaseException } from './base-exception.js';
/**
* 校验异常
*/
export class ValidateException extends BaseException {
constructor(message) {
super(
'ValidateException',
Constants.res.validation.code,
message ? message : Constants.res.validation.message
);
}
}
@@ -0,0 +1,10 @@
import { Constants } from '../constants.js';
import { BaseException } from './base-exception.js';
/**
* 需要vip异常
*/
export class NeedVIPException extends BaseException {
constructor(message) {
super('NeedVIPException', Constants.res.needvip.code, message ? message : Constants.res.needvip.message);
}
}