Skip to content
API/ParamCollisionError

ParamCollisionError

src/errors/param-collision.error.ts2 public methodsclass

Thrown by generateUri() when a parameter set with setParam() collides with one the driver emits.

Two keys collide when they are equal, or when one is the other followed by [ — page against JSON:API’s page[number] — because a backend that parses brackets would merge or overwrite them. Emitting both would silently duplicate or override the driver’s parameter, so the builder refuses.

The check runs against the URI the driver actually generated, so a key is free until the driver needs it: setParam('sort', …) works until addSort() makes the driver emit sort itself. Pagination keys are the exception — the next page’s URI is checked too, so a key a driver leaves out of page 1 (PostgREST offset, OData $skip) collides on every page.

new ParamCollisionError(key: string, driverKey: string, driver?: DriverId)
Parameter Type Description
key string The key passed to setParam()
driverKey string The colliding key the driver emits
driver DriverId The active driver, when known
Property Type Description
cause unknown —
code QubeeErrorCode Machine-readable identifier for this failure.
context Record<string, unknown> The values that produced the error, when they aid diagnosis.
driver DriverId The driver that emits the colliding parameter, when known.
driverKey string The colliding key the driver emits.
key string The key passed to setParam().
message string —
name string —
stack string —
stackTraceLimit number 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.
captureStackTrace(targetObject: object, constructorOpt?: Function): void

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();
Parameter Type Description
targetObject object —
constructorOpt Function —
prepareStackTrace(err: Error, stackTraces: CallSite[]): any
Parameter Type Description
err Error —
stackTraces CallSite[] —