UNPKG

error-lib

Version:

Standard Error Library for JavaScript/TypeScript projects (NodeJS & Browsers)

31 lines 1.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RouteNotFoundError = void 0; const not_found_error_1 = require("./not_found_error"); class RouteNotFoundError extends not_found_error_1.NotFoundError { /** * * @param route Route or path name * @param method Method * @param message Custom error message * @param opts Extra options */ constructor(route, method, message, opts) { var _a; // ensure there's always a valid error message message = message !== null && message !== void 0 ? message : `RouteNotFoundError: Route '${[method, route] .filter((_) => typeof _ === 'string' && _.length > 0) .join(': ')}' was not found`; super(message, { cause: opts === null || opts === void 0 ? void 0 : opts.cause, code: (_a = opts === null || opts === void 0 ? void 0 : opts.code) !== null && _a !== void 0 ? _a : 'E_ROUTE_NOT_FOUND', }); this.route = route; this.method = method; Error.captureStackTrace(this, RouteNotFoundError); Object.setPrototypeOf(this, RouteNotFoundError.prototype); } } exports.RouteNotFoundError = RouteNotFoundError; //# sourceMappingURL=route_not_found_error.js.map