feat: 在OakException中添加symbol以标识,并提供isOakException函数判断是否为OakException
This commit is contained in:
parent
caad35beea
commit
b9a6b26b13
|
|
@ -1,10 +1,13 @@
|
|||
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;
|
||||
|
|
@ -200,3 +203,4 @@ export declare function makeException<ED extends EntityDict & BaseEntityDict>(da
|
|||
opRecords: OpRecord<ED>[];
|
||||
[A: string]: any;
|
||||
}): OakException<ED> | undefined;
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -1,13 +1,19 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.OakApplicationHasToUpgrade = exports.OakSocketConnectException = exports.OakExternalException = exports.OakPreConditionUnsetException = exports.OakDeadlock = exports.OakCongruentRowExists = exports.OakRowLockedException = exports.OakUnloggedInException = exports.OakDataInvisibleException = exports.OakOperationUnpermittedException = exports.OakAttrCantUpdateException = exports.OakAttrNotNullException = exports.OakInputIllegalException = exports.OakRowInconsistencyException = exports.OakSignatureVerificationException = exports.OakClockDriftException = exports.OakServerProxyException = exports.OakNetworkException = exports.OakImportDataParseException = exports.OakUniqueViolationException = exports.OakUserException = exports.OakRowUnexistedException = exports.OakOperExistedException = exports.OakNoRelationDefException = exports.OakDataException = exports.OakPartialSuccess = exports.OakMakeSureByMySelfException = exports.OakRequestTimeoutException = exports.OakException = void 0;
|
||||
exports.isOakException = isOakException;
|
||||
exports.makeException = makeException;
|
||||
const relation_1 = require("../store/relation");
|
||||
const lodash_1 = require("../utils/lodash");
|
||||
const OAK_EXCEPTION_SYMBOL = Symbol.for('oak-domain:exception');
|
||||
function isOakException(obj) {
|
||||
return obj && obj[OAK_EXCEPTION_SYMBOL] === true;
|
||||
}
|
||||
class OakException extends Error {
|
||||
opRecords;
|
||||
_module;
|
||||
params;
|
||||
[OAK_EXCEPTION_SYMBOL] = true;
|
||||
constructor(message, _module, params) {
|
||||
super(message);
|
||||
this._module = _module;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Buffer } from 'buffer';
|
||||
import { Buffer, WithImplicitCoercion } from 'buffer';
|
||||
declare function percentEncode(c: number): string;
|
||||
declare function percentDecode(input: Buffer): Buffer<ArrayBuffer>;
|
||||
declare function serializeUrlencoded(tuples: any[], encodingOverride?: undefined): string;
|
||||
|
|
|
|||
|
|
@ -5,10 +5,18 @@ import { EntityDict, OpRecord, SelectOpResult } from "./Entity";
|
|||
import { EntityDict as BaseEntityDict } from '../base-app-domain';
|
||||
import { pick } from '../utils/lodash';
|
||||
|
||||
const OAK_EXCEPTION_SYMBOL = Symbol.for('oak-domain:exception');
|
||||
|
||||
export function isOakException(obj: any): obj is OakException<any> {
|
||||
return obj && obj[OAK_EXCEPTION_SYMBOL] === true;
|
||||
}
|
||||
|
||||
export class OakException<ED extends EntityDict & BaseEntityDict> extends Error {
|
||||
opRecords: OpRecord<ED>[];
|
||||
_module?: string;
|
||||
params?: Record<string, any>;
|
||||
[OAK_EXCEPTION_SYMBOL] = true;
|
||||
|
||||
constructor(message?: string, _module?: string, params?: Record<string, any>) {
|
||||
super(message);
|
||||
this._module = _module;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Buffer } from 'buffer';
|
||||
import { Buffer, WithImplicitCoercion } from 'buffer';
|
||||
import { isASCIIHex } from './infra';
|
||||
|
||||
function strictlySplitByteSequence(buf: Buffer, cp: number) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue