constructor
quic.QuicError.constructor
Not implemented in Bun
import { QuicError } from 'node:quic';
const err = new QuicError('rejecting stream', { errorCode: 0x10cn });
console.log(err.code); // 'ERR_QUIC_STREAM_ABORTED'
console.log(err.errorCode); // 268n
console.log(err.type); // 'application'
const custom = new QuicError('custom failure', {
errorCode: 0x10cn,
code: 'ERR_MY_QUIC_FAILURE',
});
console.log(custom.code); // 'ERR_MY_QUIC_FAILURE'A human-readable description of the error.
Referenced types
interface QuicErrorOptions
- code?: string
The Node.js-style error code string assigned to
error.code. Defaults to'ERR_QUIC_STREAM_ABORTED'. - errorCode?: number | bigint
The numeric QUIC error code. Numbers are coerced to
BigInt. Must be a non-negative 62-bit unsigned varint (0n <= errorCode <= 2n ** 62n - 1n). - type?: 'transport' | 'application'
Either
'application'(default) or'transport'. Indicates whether the code is defined by the negotiated application protocol (e.g. RFC 9114 for HTTP/3) or by the QUIC transport layer (RFC 9000). Stream resets always carry application codes, so the default is'application'.
class QuicError
A QuicError is an Error subclass that carries an explicit numeric QUIC error code. Use it to abort a QUIC stream or session with a specific application-protocol-defined error code rather than letting the implementation pick a generic fallback.
The class is exported from node:quic:
import { QuicError } from 'node:quic';When a QuicError is supplied to APIs that emit a wire frame (writer.fail(), stream.destroy()), the QUIC stack uses error.errorCode as the wire code for the resulting frame. When any other value is supplied (for example a plain Error), the implementation falls back to the negotiated application protocol's "internal error" code (H3_INTERNAL_ERROR (0x102) for HTTP/3, or the QUIC transport-layer INTERNAL_ERROR (0x1) for raw QUIC).
The Node.js error code (error.code) defaults to 'ERR_QUIC_STREAM_ABORTED'. Callers who need a more specific code string can override it via options.code — the numeric QUIC code is unaffected.
The Node.js error code is fixed at 'ERR_QUIC_STREAM_ABORTED' so that catch blocks can distinguish a QuicError from other Node.js errors without checking the prototype chain. The numeric QUIC code lives on the separate error.errorCode property to avoid colliding with the Node.js convention that error.code is a string.
- readonly type: 'transport' | 'application'
Either
'application'or'transport'. Indicates the namespace oferror.errorCode. - static stackTraceLimit: number
The
Error.stackTraceLimitproperty specifies the number of stack frames collected by a stack trace (whether generated bynew Error().stackorError.captureStackTrace(obj)).The default value is
10but 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.
- targetObject: object,constructorOpt?: Function): void;
Create .stack property on a target object