UNPKG

@nahkies/typescript-koa-runtime

Version:

Runtime package for code generated by @nahkies/openapi-code-generator using the typescript-koa template

31 lines 1.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.KoaRuntimeError = 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 KoaRuntimeError extends Error { phase; constructor(message, cause, phase) { super(message, { cause }); this.phase = phase; } static RequestError(cause, inputType) { return new KoaRuntimeError(`Request validation failed parsing ${inputType}`, cause, "request_validation"); } static HandlerError(cause) { return new KoaRuntimeError("Request handler threw unhandled exception", cause, "request_handler"); } static ResponseError(cause) { return new KoaRuntimeError("Response body failed validation", cause, "response_validation"); } static isKoaError(err) { return err instanceof KoaRuntimeError; } } exports.KoaRuntimeError = KoaRuntimeError; //# sourceMappingURL=errors.js.map