@solid/community-server
Version:
Community Solid Server: an open and modular implementation of the Solid specifications
28 lines • 1.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.StatusHandler = void 0;
const asynchronous_handlers_1 = require("asynchronous-handlers");
const HandlerUtil_1 = require("./HandlerUtil");
/**
* Wraps around an {@link AsyncHandler} to make sure all errors thrown are an {@link HttpError}.
* In the case of an {@link AggregateError} containing HttpErrors,
* the status code will be determined based on what makes most sense for them.
*/
class StatusHandler extends asynchronous_handlers_1.AsyncHandler {
handler;
constructor(handler) {
super();
this.handler = handler;
}
async canHandle(input) {
return (0, HandlerUtil_1.ensureHttpError)(async () => this.handler.canHandle(input));
}
async handle(input) {
return (0, HandlerUtil_1.ensureHttpError)(async () => this.handler.handle(input));
}
async handleSafe(input) {
return (0, HandlerUtil_1.ensureHttpError)(async () => this.handler.handleSafe(input));
}
}
exports.StatusHandler = StatusHandler;
//# sourceMappingURL=StatusHandler.js.map