Appearance
@loontail/minecraft-kit v0.5.0 / MinecraftKitError
Class: MinecraftKitError
The single error class thrown by every public API in @loontail/minecraft-kit.
Use isMinecraftKitError or isErrorCode for type-narrowing in catch blocks.
Extends
Error
Constructors
new MinecraftKitError()
ts
new MinecraftKitError(
code,
message,
options): MinecraftKitErrorParameters
| Parameter | Type |
|---|---|
code | MinecraftKitErrorCode |
message | string |
options | object |
options.cause? | unknown |
options.context? | MinecraftKitErrorContext |
Returns
Overrides
Error.constructor
Source
Properties
| Property | Modifier | Type | Default value | Description | Overrides | Inherited from |
|---|---|---|---|---|---|---|
cause? | public | unknown | undefined | - | Error.cause | Error.cause |
code | readonly | MinecraftKitErrorCode | undefined | Stable discriminator. | - | - |
context | readonly | Readonly<MinecraftKitErrorContext> | undefined | Structured context; safe to serialize. | - | - |
message | public | string | undefined | - | Error.message | Error.message |
name | readonly | "MinecraftKitError" | "MinecraftKitError" | - | Error.name | Error.name |
stack? | public | string | undefined | - | Error.stack | Error.stack |
stackTraceLimit | static | number | undefined | The The default value is If set to a non-number value, or set to a negative number, stack traces will not capture any frames. | Error.stackTraceLimit | Error.stackTraceLimit |
Methods
toJSON()
ts
toJSON(): Record<string, unknown>JSON-friendly representation.
Returns
Record<string, unknown>
Source
captureStackTrace()
ts
static captureStackTrace(targetObject, constructorOpt?): voidCreates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.
js
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:
js
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
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Error.captureStackTrace
Source
node_modules/@types/node/globals.d.ts:52
prepareStackTrace()
ts
static prepareStackTrace(err, stackTraces): anyParameters
| Parameter | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
Inherited from
Error.prepareStackTrace
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Source
node_modules/@types/node/globals.d.ts:56