error-lib
Version:
Standard Error Library for JavaScript/TypeScript projects (NodeJS & Browsers)
27 lines • 1.12 kB
JavaScript
import { NotFoundError, } from './not_found_error';
export class RouteNotFoundError extends 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);
}
}
//# sourceMappingURL=route_not_found_error.js.map