diffusion
Version:
Diffusion JavaScript client
27 lines (26 loc) • 756 B
JavaScript
;
/**
* @module Client
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.create = void 0;
/**
* Factory for command services, wrapping the service implementation to catch
* errors and dispatch an appropriate error response to the request callback.
*
* @param service the command service handler function
* @return command service wrapper
*/
function create(service) {
return {
onRequest: function (internal, message, callback) {
try {
service(internal, message, callback);
}
catch (e) {
callback.fail(internal.getContext().ErrorReason.CALLBACK_EXCEPTION, e.message);
}
}
};
}
exports.create = create;