跳到主要内容

RxDBPartialSyncError<T>

Defined in: packages/rxdb/src/RxDBError.ts:37

部分同步错误 —— 同步在中途失败,但已经应用的部分不会被撤销。

Remarks​

pull 按仓库逐个应用变更并逐个推进水位线,中途失败时前面若干仓库已落库、 水位线也已前移。此前这种情况直接上抛原始错误,调用方无从得知已应用了多少, 重试会从新水位线继续,中间那段既不重放也不告警。

收到本错误时:

  • result 是失败前已完成部分的真实统计,可直接用于展示/记账;
  • cause 是中断同步的原始错误;
  • 不要假设数据回到了同步前的状态。

Example​

try {
await rxdb.syncManager.pull({ fetchAll: true });
} catch (error) {
if (error instanceof RxDBPartialSyncError) {
console.warn(`已应用 ${error.result.applied} 条后中断`, error.cause);
} else {
throw error;
}
}

Extends​

Type Parameters​

Type ParameterDefault typeDescription
Tunknown该次同步的结果类型(如 PullResult)

Constructors​

Constructor​

new RxDBPartialSyncError<T>(result, cause): RxDBPartialSyncError<T>;

Defined in: packages/rxdb/src/RxDBError.ts:38

Parameters​

ParameterTypeDescription
resultT失败前已完成部分的统计
causeError中断同步的原始错误

Returns​

RxDBPartialSyncError<T>

Overrides​

RxDBError.constructor

Properties​

cause​

readonly cause: Error;

Defined in: packages/rxdb/src/RxDBError.ts:42

中断同步的原始错误

Inherited from​

RxDBError.cause


message​

message: string;

Defined in: node_modules/.pnpm/typescript@6.0.3_patch_hash=ef3c2292deb88eb14130359d5acc1febc0226af46b7b945db6c7250c6cb4efbb/node_modules/typescript/lib/lib.es5.d.ts:1075

Inherited from​

RxDBError.message


name​

name: string;

Defined in: node_modules/.pnpm/typescript@6.0.3_patch_hash=ef3c2292deb88eb14130359d5acc1febc0226af46b7b945db6c7250c6cb4efbb/node_modules/typescript/lib/lib.es5.d.ts:1074

Inherited from​

RxDBError.name


result​

readonly result: T;

Defined in: packages/rxdb/src/RxDBError.ts:40

失败前已完成部分的统计


stack?​

optional stack?: string;

Defined in: node_modules/.pnpm/typescript@6.0.3_patch_hash=ef3c2292deb88eb14130359d5acc1febc0226af46b7b945db6c7250c6cb4efbb/node_modules/typescript/lib/lib.es5.d.ts:1076

Inherited from​

RxDBError.stack


stackTraceLimit​

static stackTraceLimit: number;

Defined in: node_modules/.pnpm/@types+node@26.6.3/node_modules/@types/node/globals.d.ts:67

The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)).

The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed.

If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

Inherited from​

RxDBError.stackTraceLimit

Methods​

captureStackTrace()​

static captureStackTrace(targetObject, constructorOpt?): void;

Defined in: node_modules/.pnpm/@types+node@26.6.3/node_modules/@types/node/globals.d.ts:51

Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`

The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

function a() {
b();
}

function b() {
c();
}

function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;

// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}

a();

Parameters​

ParameterType
targetObjectobject
constructorOpt?Function

Returns​

void

Inherited from​

RxDBError.captureStackTrace


prepareStackTrace()​

static prepareStackTrace(err, stackTraces): any;

Defined in: node_modules/.pnpm/@types+node@26.6.3/node_modules/@types/node/globals.d.ts:55

Parameters​

ParameterType
errError
stackTracesCallSite[]

Returns​

any

See​

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Inherited from​

RxDBError.prepareStackTrace