跳到主要内容

HttpRequestBuildError

Defined in: packages/rxdb-adapter-http/src/errors.ts:268

请求在发出之前就构造失败(US-212 AC#12 / #34)。

Remarks​

存在的唯一理由是把「本地数据/配置有问题」从「网络断了」里摘出来。 JSON.stringify 遇 bigint 抛的是 TypeError,与 fetch 传输失败抛的完全同型; 若让它落进 classify(),就会被包成 NetworkOfflineError, 进而被 offlineFallback 静默换成陈旧缓存——脏数据与配置 bug 从此永远浮不出来。

五种成因共用一个类、由 HttpRequestBuildError.reason 区分,理由同 HttpPaginationError:调用侧的处置一致(修本地,别重试), 拆成五个类只会让 catch 侧多写四个 instanceof。

method 与 url 两条针对的是同一个陷阱的另外两个入口:fetch 对 「GET 带 body」与「URL 解析不了」抛的都是裸 TypeError,与传输失败同型, 落进 classify() 后同样会变成一次静默的缓存降级。它们不是理论边界—— 把 onFetchMetadata 的方法覆盖成 GET(它恒带 body)就能走到第一条。

id 那一条是数据问题而不是配置问题,这正是它不归 HttpConfigError 的理由: 主键为空时 PUT /Recipe/ 会被不少路由框架读成集合端点,一次更新静默变成一次批量写; 而没有任何配置项改了能修好它,报成配置错误只会把排查方向指向一个不存在的选项。

不带 status,但也不是网络错误:isNetworkError 的 5 条判据一条都不命中, 于是既不会被降级回退,也不会被误报成远端故障。

Extends​

Constructors​

Constructor​

new HttpRequestBuildError(
reason,
operation,
detail
): HttpRequestBuildError;

Defined in: packages/rxdb-adapter-http/src/errors.ts:269

Parameters​

ParameterType
reasonHttpRequestBuildFailure
operationstring
detailstring

Returns​

HttpRequestBuildError

Overrides​

HttpAdapterError.constructor

Properties​

cause?​

optional cause?: unknown;

Defined in: node_modules/.pnpm/typescript@6.0.3_patch_hash=ef3c2292deb88eb14130359d5acc1febc0226af46b7b945db6c7250c6cb4efbb/node_modules/typescript/lib/lib.es2022.error.d.ts:24

Inherited from​

HttpAdapterError.cause


code​

readonly code: string;

Defined in: packages/rxdb-adapter-http/src/errors.ts:29

Inherited from​

HttpAdapterError.code


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​

HttpAdapterError.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​

HttpAdapterError.name


operation​

readonly operation: string;

Defined in: packages/rxdb-adapter-http/src/errors.ts:271


reason​

readonly reason: HttpRequestBuildFailure;

Defined in: packages/rxdb-adapter-http/src/errors.ts:270


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​

HttpAdapterError.stack


stackTraceLimit​

static stackTraceLimit: number;

Defined in: node_modules/.pnpm/@types+node@26.6.4/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​

HttpAdapterError.stackTraceLimit

Methods​

captureStackTrace()​

static captureStackTrace(targetObject, constructorOpt?): void;

Defined in: node_modules/.pnpm/@types+node@26.6.4/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​

HttpAdapterError.captureStackTrace


prepareStackTrace()​

static prepareStackTrace(err, stackTraces): any;

Defined in: node_modules/.pnpm/@types+node@26.6.4/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​

HttpAdapterError.prepareStackTrace