From b9a6b26b13596b4f9d152f995cdee73da695b8c0 Mon Sep 17 00:00:00 2001 From: qcqcqc <1220204124@zust.edu.cn> Date: Mon, 22 Dec 2025 14:20:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9C=A8OakException=E4=B8=AD=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0symbol=E4=BB=A5=E6=A0=87=E8=AF=86=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E6=8F=90=E4=BE=9BisOakException=E5=87=BD=E6=95=B0=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E6=98=AF=E5=90=A6=E4=B8=BAOakException?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/types/Exception.d.ts | 4 ++++ lib/types/Exception.js | 6 ++++++ lib/utils/url/whatwg-url/lib/urlencoded.d.ts | 2 +- src/types/Exception.ts | 8 ++++++++ src/utils/url/whatwg-url/lib/urlencoded.ts | 2 +- 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/types/Exception.d.ts b/lib/types/Exception.d.ts index 8cad0b5..d85ed77 100644 --- a/lib/types/Exception.d.ts +++ b/lib/types/Exception.d.ts @@ -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; export declare class OakException extends Error { opRecords: OpRecord[]; _module?: string; params?: Record; + [OAK_EXCEPTION_SYMBOL]: boolean; constructor(message?: string, _module?: string, params?: Record); addData(entity: T, rows: Partial[], schema: StorageSchema): void; setOpRecords(opRecords: OpRecord[]): void; @@ -200,3 +203,4 @@ export declare function makeException(da opRecords: OpRecord[]; [A: string]: any; }): OakException | undefined; +export {}; diff --git a/lib/types/Exception.js b/lib/types/Exception.js index b97e6de..599f476 100644 --- a/lib/types/Exception.js +++ b/lib/types/Exception.js @@ -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; diff --git a/lib/utils/url/whatwg-url/lib/urlencoded.d.ts b/lib/utils/url/whatwg-url/lib/urlencoded.d.ts index 8adf704..76f9344 100644 --- a/lib/utils/url/whatwg-url/lib/urlencoded.d.ts +++ b/lib/utils/url/whatwg-url/lib/urlencoded.d.ts @@ -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; declare function serializeUrlencoded(tuples: any[], encodingOverride?: undefined): string; diff --git a/src/types/Exception.ts b/src/types/Exception.ts index 20091cd..895744e 100644 --- a/src/types/Exception.ts +++ b/src/types/Exception.ts @@ -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 { + return obj && obj[OAK_EXCEPTION_SYMBOL] === true; +} + export class OakException extends Error { opRecords: OpRecord[]; _module?: string; params?: Record; + [OAK_EXCEPTION_SYMBOL] = true; + constructor(message?: string, _module?: string, params?: Record) { super(message); this._module = _module; diff --git a/src/utils/url/whatwg-url/lib/urlencoded.ts b/src/utils/url/whatwg-url/lib/urlencoded.ts index e729374..6a0856a 100644 --- a/src/utils/url/whatwg-url/lib/urlencoded.ts +++ b/src/utils/url/whatwg-url/lib/urlencoded.ts @@ -1,4 +1,4 @@ -import { Buffer } from 'buffer'; +import { Buffer, WithImplicitCoercion } from 'buffer'; import { isASCIIHex } from './infra'; function strictlySplitByteSequence(buf: Buffer, cp: number) {