@arifwidianto/rpc-agent
Version:
RPC Agent for both client and server, extends more methods easily
49 lines (48 loc) • 1.3 kB
TypeScript
import { JSONValue } from "./common.interface";
export declare enum ErrorCode {
PARSE_ERROR = -32700,
INVALID_REQUEST = -32600,
METHOD_NOT_FOUND = -32601,
INVALID_PARAMS = -32602,
INTERNAL_ERROR = -32603,
SERVER_ERROR = -32000,
EXTENSION_NOT_FOUND = -32001,
EXTENSION_INIT_FAILED = -32002,
VALIDATION_FAILED = -32003,
SERVICE_UNAVAILABLE = -32004,
HTTP_SUCCESS = 200,
HTTP_CREATED = 201,
HTTP_BAD_REQUEST = 400,
HTTP_UNAUTHORIZED = 401,
HTTP_NOT_FOUND = 404,
HTTP_METHOD_NOT_ALLOWED = 405,
HTTP_VALIDATION_FAILED = 422,
HTTP_INTERNAL_ERROR = 500,
HTTP_NOT_IMPLEMENTED = 501,
HTTP_SERVICE_UNAVAILABLE = 503,
EXT_ERROR = 1000,
EXT_NOT_FOUND = 1001,
EXT_INIT_FAILED = 1002,
EXT_PARSE_ERROR = 1003,
UNAUTHORIZED = 401,
FORBIDDEN = 403,
TIMEOUT = 408,
RATE_LIMITED = 429
}
export interface ErrorDetails {
errorId?: string;
code: ErrorCode;
message: string;
details?: Record<string, JSONValue>;
field?: string;
timestamp?: string;
source?: string;
requestId?: string | number | null;
}
export interface RpcErrorParams {
code: ErrorCode;
message: string;
details?: Record<string, JSONValue>;
requestId?: string | number | null;
source?: string;
}