Constructs a new RPCError instance.
Optionalvalue: string | number | RpcErrorThe parsed variable value from the Telegram error string, if any.
OptionalrpcName: stringThe name of the causing RPC method.
OptionalisUnknown: booleanTrue if the error is unrecognized.
OptionalisSigned: booleanTrue if the error code is signed.
Optional Internal_Internal sign flag. True if the Telegram error code was negative.
Optional Internal_Internal flag indicating whether the error code or string was unrecognized.
Optional Internal_The name of the specific RPC method that triggered this error.
OptionalcauseThe cause of the error.
The HTTP/MTProto status code returned. E.g. 400 or 420.
The Telegram-specific alphanumeric error code identifier. E.g. FLOOD_WAIT_X.
The formatted, human-readable error message.
The class name representing this error instance.
OptionalstackOptionalvalueThe optional value parsed from the Telegram error string (such as the number of seconds to wait).
StaticstackThe 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.
Protected_ProtectedFormats the final exception message by embedding variables and the causing RPC method name.
Serializes the RPC error object to a clean JSON-compatible representation.
A plain object containing error properties and the stack trace.
Formats the error into a structured string.
A string starting with the constructor name followed by a pretty JSON payload.
StaticcaptureCreates 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();
OptionalconstructorOpt: FunctionCreate .stack property on a target object
OptionalconstructorOpt: FunctionStaticisIndicates whether the argument provided is a built-in Error instance or not.
Check if a value is an instance of Error
The value to check
True if the value is an instance of Error, false otherwise
StaticprepareStaticraiseAnalyzes a raw Telegram RpcError object and raises a matching, highly-specialized RPC sub-exception.
Fallback error class used when the Telegram API returns an unrecognized error code or message.