UNPKG

mqrpc

Version:

💫 Easy RPC over RabbitMQ

43 lines (42 loc) • 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class RpcServerError extends Error { constructor(message) { super(message); this.name = this.constructor.name; } get includeStack() { return false; } toObject() { const error = { message: this.message, name: this.name }; if (this.includeStack) error.stack = this.stack; return error; } } exports.RpcServerError = RpcServerError; class NoSuchProcedure extends RpcServerError { constructor(procedure) { super(`No procedure named "${procedure}" has been registered`); } } exports.NoSuchProcedure = NoSuchProcedure; class InvalidCall extends RpcServerError { } exports.InvalidCall = InvalidCall; class ProcedureFailed extends RpcServerError { constructor(err) { super(`Operation failed with error: ${err.message}`); this.stack = err.stack; this.cause = err; } toObject() { return Object.assign(super.toObject(), { cause: { name: this.cause.name, stack: this.cause.stack, message: this.cause.message } }); } } exports.ProcedureFailed = ProcedureFailed;