ws-rmi
Version:
A Remote Method Invocation implementation written in JavaScript utilising the WebSocket protocol
19 lines (18 loc) • 1.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateRMIRemoteError = exports.createRMIRemoteError = void 0;
const RMIMessage_1 = require("./RMIMessage");
const JSONValidation_1 = require("../JSONValidation");
/**
* Creates an object adhering to the RMI Remote Error schema.
*
* @param id The ID of the message to use.
* @param error The error that occurred on the remote. NOTE: This should be generic to avoid clients obtaining
* potentially sensitive information about the remote, such as stack trace, etc.
*/
const createRMIRemoteError = (id, error) => (0, RMIMessage_1.createRMIMessage)(id, "RESPONSE_ERROR", { error });
exports.createRMIRemoteError = createRMIRemoteError;
/**
* Validates that the given message is an RMI remote error.
*/
exports.validateRMIRemoteError = (0, RMIMessage_1.createRMIMessageValidator)((data) => (0, JSONValidation_1.isObject)(data) && (0, JSONValidation_1.hasPropertyOfType)(data, "error", JSONValidation_1.isString));