Bot / structs/ClientError / ClientError
structs/ClientError.ClientError
| Name | Type |
|---|---|
T |
extends keyof typeof ErrorCodes |
-
Error↳
ClientError
• new ClientError<T>(code, ...args)
Initializes a new ClientError instance.
| Name | Type |
|---|---|
T |
extends "INVALID_DIRECTORY" | "INVALID_MODULE" | "INVALID_HANDLER" | "DUPLICATE_MODULE" | "NON_TS_FILE" | "UNKNOWN_EMITTER" | "MISSING_JSON_FILE" | "NON_JSON_FILE" | "INVALID_JSON" |
| Name | Type | Description |
|---|---|---|
code |
T |
The string representation of the error. |
...args |
Parameters<{ DUPLICATE_MODULE: (__namedParameters: { handler: string ; module: string }) => string ; INVALID_DIRECTORY: (options: { path: string }) => string ; INVALID_HANDLER: (__namedParameters: { handler: string ; module: string }) => string ; INVALID_JSON: (path: string) => string ; INVALID_MODULE: (__namedParameters: { module: string ; path: string }) => string ; MISSING_JSON_FILE: (path: string) => string ; NON_JSON_FILE: (path: string) => string ; NON_TS_FILE: (__namedParameters: { name: string ; path: string }) => string ; UNKNOWN_EMITTER: (__namedParameters: { emitter: string ; listener: string }) => string }[T]> |
Any arguments used to construct the error message, if applicable. |
Error.constructor
src/structs/ClientError.ts:166
• args: Parameters<{ DUPLICATE_MODULE: (__namedParameters: { handler: string ; module: string }) => string ; INVALID_DIRECTORY: (options: { path: string }) => string ; INVALID_HANDLER: (__namedParameters: { handler: string ; module: string }) => string ; INVALID_JSON: (path: string) => string ; INVALID_MODULE: (__namedParameters: { module: string ; path: string }) => string ; MISSING_JSON_FILE: (path: string) => string ; NON_JSON_FILE: (path: string) => string ; NON_TS_FILE: (__namedParameters: { name: string ; path: string }) => string ; UNKNOWN_EMITTER: (__namedParameters: { emitter: string ; listener: string }) => string }[T]>
Arguments that contain additional information about the error, if applicable.
MessageGenerate represents a list of functions used to construct a string
for a given error code. These functions may accept arguments which is used
within the constructed string, if specified, this property will reference
the arguments passed to the message generator.
src/structs/ClientError.ts:157
• code: T
The code representing the thrown error.
This property will represent the string representation of the thrown error, which can be used to handle the error in a specific error if desired.
src/structs/ClientError.ts:146
• message: string
Error.message
node_modules/.pnpm/typescript@5.1.6/node_modules/typescript/lib/lib.es5.d.ts:1068
• name: string
Error.name
node_modules/.pnpm/typescript@5.1.6/node_modules/typescript/lib/lib.es5.d.ts:1067
• Optional stack: string
Error.stack
node_modules/.pnpm/typescript@5.1.6/node_modules/typescript/lib/lib.es5.d.ts:1069
▪ Static Optional prepareStackTrace: (err: Error, stackTraces: CallSite[]) => any
▸ (err, stackTraces): any
Optional override for formatting stack traces
| Name | Type |
|---|---|
err |
Error |
stackTraces |
CallSite[] |
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Error.prepareStackTrace
node_modules/.pnpm/@types+node@20.4.8/node_modules/@types/node/globals.d.ts:11
▪ Static stackTraceLimit: number
Error.stackTraceLimit
node_modules/.pnpm/@types+node@20.4.8/node_modules/@types/node/globals.d.ts:13
▸ is<T>(code): this is ClientError<T>
Determines the specific type of error that occured.
When catching an instance of ClientError, by default, the inferred type
of the error is unknown. This method implements a type guard to determine
the type of error that occured, which can be used to handle the error in a
specific way.
| Name | Type |
|---|---|
T |
extends ErrorCodes |
| Name | Type | Description |
|---|---|---|
code |
T |
The code to check against. |
this is ClientError<T>
Whether if the ClientError is of the specified type.
Example
try {
// ...
} catch (error) {
if (error instanceof ClientError) {
// Uknown `ClientError` error
if (error.is(ErrorCodes.INVALID_DIRECTORY)) {
// `INVALID_DIRECTORY` error
}
}
// Unknown error
}src/structs/ClientError.ts:202
▸ Static captureStackTrace(targetObject, constructorOpt?): void
Create .stack property on a target object
| Name | Type |
|---|---|
targetObject |
object |
constructorOpt? |
Function |
void
Error.captureStackTrace
node_modules/.pnpm/@types+node@20.4.8/node_modules/@types/node/globals.d.ts:4