@nahkies/typescript-express-runtime
Version:
Runtime package for code generated by @nahkies/openapi-code-generator using the typescript-express template
31 lines • 1.29 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExpressRuntimeError = exports.RequestInputType = void 0;
var RequestInputType;
(function (RequestInputType) {
RequestInputType["RouteParam"] = "route params";
RequestInputType["QueryString"] = "querystring";
RequestInputType["RequestBody"] = "request body";
RequestInputType["RequestHeader"] = "request header";
})(RequestInputType || (exports.RequestInputType = RequestInputType = {}));
class ExpressRuntimeError extends Error {
phase;
constructor(message, cause, phase) {
super(message, { cause });
this.phase = phase;
}
static RequestError(cause, inputType) {
return new ExpressRuntimeError(`Request validation failed parsing ${inputType}`, cause, "request_validation");
}
static HandlerError(cause) {
return new ExpressRuntimeError("Request handler threw unhandled exception", cause, "request_handler");
}
static ResponseError(cause) {
return new ExpressRuntimeError("Response body failed validation", cause, "response_validation");
}
static isExpressError(err) {
return err instanceof ExpressRuntimeError;
}
}
exports.ExpressRuntimeError = ExpressRuntimeError;
//# sourceMappingURL=errors.js.map