oak-domain/lib/types/Exception.d.ts

207 lines
8.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { StorageSchema } from ".";
import { EntityDict, OpRecord } from "./Entity";
import { EntityDict as BaseEntityDict } from '../base-app-domain';
declare const OAK_EXCEPTION_SYMBOL: unique symbol;
export declare function isOakException(obj: any): obj is OakException<any>;
export declare class OakException<ED extends EntityDict & BaseEntityDict> extends Error {
opRecords: OpRecord<ED>[];
_module?: string;
params?: Record<string, any>;
[OAK_EXCEPTION_SYMBOL]: boolean;
constructor(message?: string, _module?: string, params?: Record<string, any>);
addData<T extends keyof ED>(entity: T, rows: Partial<ED[T]['Schema']>[], schema: StorageSchema<ED>): void;
setOpRecords(opRecords: OpRecord<ED>[]): void;
getSerialData(): {
name: string;
message: string;
_module: string | undefined;
params: Record<string, any> | undefined;
opRecords: OpRecord<ED>[];
tag1: string | undefined;
tag2: boolean | undefined;
tag3: any;
};
toString(): string;
tag1?: string;
tag2?: boolean;
tag3?: any;
}
export declare class OakRequestTimeoutException<ED extends EntityDict & BaseEntityDict> extends OakException<ED> {
constructor(message?: string, ns?: string, params?: Record<string, any>);
}
export declare class OakMakeSureByMySelfException<ED extends EntityDict & BaseEntityDict> extends OakException<ED> {
}
export declare class OakPartialSuccess<ED extends EntityDict & BaseEntityDict> extends OakException<ED> {
}
export declare class OakDataException<ED extends EntityDict & BaseEntityDict> extends OakException<ED> {
}
export declare class OakNoRelationDefException<ED extends EntityDict & BaseEntityDict, T extends keyof ED> extends OakDataException<ED> {
entity: T;
actions: ED[T]['Action'][];
constructor(entity: T, actions: ED[T]['Action'][], msg?: string, _module?: string, params?: Record<string, any>);
toString(): string;
}
export declare class OakOperExistedException<ED extends EntityDict & BaseEntityDict> extends OakDataException<ED> {
}
export declare class OakRowUnexistedException<ED extends EntityDict & BaseEntityDict> extends OakDataException<ED> {
private rows;
constructor(rows: Array<{
entity: any;
selection: any;
}>, msg?: string, _module?: string, params?: Record<string, any>);
toString(): string;
getRows(): {
entity: any;
selection: any;
}[];
}
/**
* 可接受的、由用户操作造成的异常
*/
export declare class OakUserException<ED extends EntityDict & BaseEntityDict> extends OakException<ED> {
}
export declare class OakUniqueViolationException<ED extends EntityDict & BaseEntityDict> extends OakUserException<ED> {
rows: Array<{
id?: string;
attrs: string[];
}>;
constructor(rows: Array<{
id?: string;
attrs: string[];
}>, message?: string, _module?: string, params?: Record<string, any>);
}
export declare class OakImportDataParseException<ED extends EntityDict & BaseEntityDict> extends OakUserException<ED> {
line: number;
header?: string;
constructor(message: string, line: number, header?: string, _module?: string, params?: Record<string, any>);
}
/**
* 网络中断异常
*/
export declare class OakNetworkException<ED extends EntityDict & BaseEntityDict> extends OakException<ED> {
}
export declare class OakServerProxyException<ED extends EntityDict & BaseEntityDict> extends OakException<ED> {
}
export declare class OakClockDriftException<ED extends EntityDict & BaseEntityDict> extends OakException<ED> {
}
export declare class OakSignatureVerificationException<ED extends EntityDict & BaseEntityDict> extends OakException<ED> {
constructor(message?: string, _module?: string, params?: Record<string, any>);
}
/**
* 数据不一致异常,系统认为现有的数据不允许相应的动作时抛此异常
*
*/
export declare class OakRowInconsistencyException<ED extends EntityDict & BaseEntityDict> extends OakUserException<ED> {
toString(): string;
}
/**
* 当输入的数据非法时抛此异常attributes表示非法的属性
*/
export declare class OakInputIllegalException<ED extends EntityDict & BaseEntityDict> extends OakUserException<ED> {
private attributes;
private entity;
constructor(entity: keyof ED, attributes: string[], message?: string, _module?: string, params?: Record<string, any>);
getEntity(): keyof ED;
getAttributes(): string[];
addAttributesPrefix(prefix: string): void;
toString(): string;
}
/**
* 属性为空时抛的异常
*/
export declare class OakAttrNotNullException<ED extends EntityDict & BaseEntityDict> extends OakInputIllegalException<ED> {
constructor(entity: keyof ED, attributes: string[], message?: string, _module?: string, params?: Record<string, any>);
}
/**
* 属性不允许更新抛的异常前端可以用这个异常来处理update时对应属性的露出
*/
export declare class OakAttrCantUpdateException<ED extends EntityDict & BaseEntityDict> extends OakInputIllegalException<ED> {
constructor(entity: keyof ED, attributes: string[], message?: string, _module?: string, params?: Record<string, any>);
}
/**
* 用户权限不够时抛的异常
*/
export declare class OakOperationUnpermittedException<ED extends EntityDict & BaseEntityDict, T extends keyof ED> extends OakUserException<ED> {
private entity;
private operation;
private userId?;
constructor(entity: T, operation: ED[T]['Selection'] | ED[T]['Operation'], userId?: string, message?: string, _module?: string, params?: Record<string, any>);
toString(): string;
}
/**
* 用户查询权限不够抛出异常
*/
export declare class OakDataInvisibleException<ED extends EntityDict & BaseEntityDict, T extends keyof ED> extends OakUserException<ED> {
private entity;
private operation;
private userId?;
constructor(entity: T, operation: ED[T]['Selection'] | ED[T]['Operation'], userId?: string, message?: string, _module?: string, params?: Record<string, any>);
toString(): string;
}
/**
* 用户未登录抛的异常
*/
export declare class OakUnloggedInException<ED extends EntityDict & BaseEntityDict> extends OakUserException<ED> {
constructor(message?: string, _module?: string, params?: Record<string, any>);
}
/**
* 行数据被锁抛的异常
*/
export declare class OakRowLockedException<ED extends EntityDict & BaseEntityDict> extends OakUserException<ED> {
constructor(message?: string, _module?: string, params?: Record<string, any>);
}
/**
* 要插入行时,发现已经有相同的行数据
*/
export declare class OakCongruentRowExists<ED extends EntityDict & BaseEntityDict, T extends keyof ED> extends OakUserException<ED> {
private data;
private entity;
constructor(entity: T, data: ED[T]['OpSchema'], message?: string, _module?: string, params?: Record<string, any>);
getData(): ED[T]["OpSchema"];
getEntity(): T;
toString(): string;
}
/**
* 死锁抛的异常
*/
export declare class OakDeadlock<ED extends EntityDict & BaseEntityDict> extends OakUserException<ED> {
constructor(message?: string, _module?: string, params?: Record<string, any>);
}
/**
* 前置条件不满足抛的异常
*/
export declare class OakPreConditionUnsetException<ED extends EntityDict & BaseEntityDict> extends OakUserException<ED> {
entity?: keyof ED;
code?: string;
constructor(message?: string, entity?: keyof ED, code?: string, _module?: string, params?: Record<string, any>);
toString(): string;
}
/**
* 调用外部接口抛出的异常
*/
export declare class OakExternalException<ED extends EntityDict & BaseEntityDict> extends OakUserException<ED> {
code?: string;
source: string;
data?: any;
constructor(source: string, code?: string, message?: string, data?: any, _module?: string, params?: Record<string, any>);
toString(): string;
}
/**
* socket连接异常
*/
export declare class OakSocketConnectException<ED extends EntityDict & BaseEntityDict> extends OakUserException<ED> {
constructor(message?: string, _module?: string, params?: Record<string, any>);
}
export declare class OakApplicationHasToUpgrade<ED extends EntityDict & BaseEntityDict> extends OakUserException<ED> {
constructor(message?: string, _module?: string, params?: Record<string, any>);
}
export declare function makeException<ED extends EntityDict & BaseEntityDict>(data: {
name: string;
message?: string;
_module?: string;
params?: Record<string, any>;
opRecords: OpRecord<ED>[];
[A: string]: any;
}): OakException<ED> | undefined;
export {};