@hckrs/errors
Advanced tools
| import { JsonObject } from 'type-fest'; | ||
| declare type ErrorOptions = { | ||
| /** HTTP status code to be used by Express error handling. */ | ||
| status?: number; | ||
| /** The original error that caused this error. */ | ||
| cause?: unknown; | ||
| /** Additional context to be added to the error. */ | ||
| context?: JsonObject; | ||
| }; | ||
| declare class BaseError extends Error { | ||
| status?: number; | ||
| context?: JsonObject; | ||
| constructor(message: string, opts?: ErrorOptions); | ||
| } | ||
| declare class BadRequestError extends BaseError { | ||
| constructor(message: string, opts?: ErrorOptions); | ||
| } | ||
| declare class UnauthorizedError extends BaseError { | ||
| constructor(message: string, opts?: ErrorOptions); | ||
| } | ||
| declare class ForbiddenError extends BaseError { | ||
| constructor(message: string, opts?: ErrorOptions); | ||
| } | ||
| declare class NotFoundError extends BaseError { | ||
| constructor(message: string, opts?: ErrorOptions); | ||
| } | ||
| declare class TooManyRequestsError extends BaseError { | ||
| constructor(message: string, opts?: ErrorOptions); | ||
| } | ||
| declare class InternalServerError extends BaseError { | ||
| constructor(message: string, opts?: ErrorOptions); | ||
| } | ||
| declare class NotImplementedError extends BaseError { | ||
| constructor(message: string, opts?: ErrorOptions); | ||
| } | ||
| export { BadRequestError, BaseError, ErrorOptions, ForbiddenError, InternalServerError, NotFoundError, NotImplementedError, TooManyRequestsError, UnauthorizedError }; |
+114
| "use strict"; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __export = (target, all) => { | ||
| for (var name in all) | ||
| __defProp(target, name, { get: all[name], enumerable: true }); | ||
| }; | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") { | ||
| for (let key of __getOwnPropNames(from)) | ||
| if (!__hasOwnProp.call(to, key) && key !== except) | ||
| __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
| } | ||
| return to; | ||
| }; | ||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
| // src/index.ts | ||
| var src_exports = {}; | ||
| __export(src_exports, { | ||
| BadRequestError: () => BadRequestError, | ||
| BaseError: () => BaseError, | ||
| ForbiddenError: () => ForbiddenError, | ||
| InternalServerError: () => InternalServerError, | ||
| NotFoundError: () => NotFoundError, | ||
| NotImplementedError: () => NotImplementedError, | ||
| TooManyRequestsError: () => TooManyRequestsError, | ||
| UnauthorizedError: () => UnauthorizedError | ||
| }); | ||
| module.exports = __toCommonJS(src_exports); | ||
| var BaseError = class extends Error { | ||
| constructor(message, opts = {}) { | ||
| var __super = (...args) => { | ||
| super(...args); | ||
| }; | ||
| if (opts.cause) { | ||
| __super(message, { cause: opts.cause }); | ||
| } else { | ||
| __super(message); | ||
| } | ||
| this.name = this.constructor.name; | ||
| if (Error.captureStackTrace) { | ||
| Error.captureStackTrace(this, this.constructor); | ||
| } | ||
| if (opts.status) { | ||
| this.status = opts.status; | ||
| } | ||
| if (opts.context) { | ||
| this.context = opts.context; | ||
| } | ||
| } | ||
| }; | ||
| var BadRequestError = class extends BaseError { | ||
| constructor(message, opts = {}) { | ||
| opts.status = opts.status || 400; | ||
| super(message, opts); | ||
| Error.captureStackTrace(this, this.constructor); | ||
| } | ||
| }; | ||
| var UnauthorizedError = class extends BaseError { | ||
| constructor(message, opts = {}) { | ||
| opts.status = opts.status || 401; | ||
| super(message, opts); | ||
| Error.captureStackTrace(this, this.constructor); | ||
| } | ||
| }; | ||
| var ForbiddenError = class extends BaseError { | ||
| constructor(message, opts = {}) { | ||
| opts.status = opts.status || 403; | ||
| super(message, opts); | ||
| Error.captureStackTrace(this, this.constructor); | ||
| } | ||
| }; | ||
| var NotFoundError = class extends BaseError { | ||
| constructor(message, opts = {}) { | ||
| opts.status = opts.status || 404; | ||
| super(message, opts); | ||
| Error.captureStackTrace(this, this.constructor); | ||
| } | ||
| }; | ||
| var TooManyRequestsError = class extends BaseError { | ||
| constructor(message, opts = {}) { | ||
| opts.status = opts.status || 429; | ||
| super(message, opts); | ||
| Error.captureStackTrace(this, this.constructor); | ||
| } | ||
| }; | ||
| var InternalServerError = class extends BaseError { | ||
| constructor(message, opts = {}) { | ||
| opts.status = opts.status || 500; | ||
| super(message, opts); | ||
| Error.captureStackTrace(this, this.constructor); | ||
| } | ||
| }; | ||
| var NotImplementedError = class extends BaseError { | ||
| constructor(message, opts = {}) { | ||
| opts.status = opts.status || 501; | ||
| super(message, opts); | ||
| Error.captureStackTrace(this, this.constructor); | ||
| } | ||
| }; | ||
| // Annotate the CommonJS export names for ESM import in node: | ||
| 0 && (module.exports = { | ||
| BadRequestError, | ||
| BaseError, | ||
| ForbiddenError, | ||
| InternalServerError, | ||
| NotFoundError, | ||
| NotImplementedError, | ||
| TooManyRequestsError, | ||
| UnauthorizedError | ||
| }); |
| // src/index.ts | ||
| var BaseError = class extends Error { | ||
| constructor(message, opts = {}) { | ||
| var __super = (...args) => { | ||
| super(...args); | ||
| }; | ||
| if (opts.cause) { | ||
| __super(message, { cause: opts.cause }); | ||
| } else { | ||
| __super(message); | ||
| } | ||
| this.name = this.constructor.name; | ||
| if (Error.captureStackTrace) { | ||
| Error.captureStackTrace(this, this.constructor); | ||
| } | ||
| if (opts.status) { | ||
| this.status = opts.status; | ||
| } | ||
| if (opts.context) { | ||
| this.context = opts.context; | ||
| } | ||
| } | ||
| }; | ||
| var BadRequestError = class extends BaseError { | ||
| constructor(message, opts = {}) { | ||
| opts.status = opts.status || 400; | ||
| super(message, opts); | ||
| Error.captureStackTrace(this, this.constructor); | ||
| } | ||
| }; | ||
| var UnauthorizedError = class extends BaseError { | ||
| constructor(message, opts = {}) { | ||
| opts.status = opts.status || 401; | ||
| super(message, opts); | ||
| Error.captureStackTrace(this, this.constructor); | ||
| } | ||
| }; | ||
| var ForbiddenError = class extends BaseError { | ||
| constructor(message, opts = {}) { | ||
| opts.status = opts.status || 403; | ||
| super(message, opts); | ||
| Error.captureStackTrace(this, this.constructor); | ||
| } | ||
| }; | ||
| var NotFoundError = class extends BaseError { | ||
| constructor(message, opts = {}) { | ||
| opts.status = opts.status || 404; | ||
| super(message, opts); | ||
| Error.captureStackTrace(this, this.constructor); | ||
| } | ||
| }; | ||
| var TooManyRequestsError = class extends BaseError { | ||
| constructor(message, opts = {}) { | ||
| opts.status = opts.status || 429; | ||
| super(message, opts); | ||
| Error.captureStackTrace(this, this.constructor); | ||
| } | ||
| }; | ||
| var InternalServerError = class extends BaseError { | ||
| constructor(message, opts = {}) { | ||
| opts.status = opts.status || 500; | ||
| super(message, opts); | ||
| Error.captureStackTrace(this, this.constructor); | ||
| } | ||
| }; | ||
| var NotImplementedError = class extends BaseError { | ||
| constructor(message, opts = {}) { | ||
| opts.status = opts.status || 501; | ||
| super(message, opts); | ||
| Error.captureStackTrace(this, this.constructor); | ||
| } | ||
| }; | ||
| export { | ||
| BadRequestError, | ||
| BaseError, | ||
| ForbiddenError, | ||
| InternalServerError, | ||
| NotFoundError, | ||
| NotImplementedError, | ||
| TooManyRequestsError, | ||
| UnauthorizedError | ||
| }; |
+1
-1
| { | ||
| "name": "@hckrs/errors", | ||
| "version": "0.0.1", | ||
| "version": "0.0.2", | ||
| "main": "./dist/index.js", | ||
@@ -5,0 +5,0 @@ "module": "./dist/index.mjs", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
7814
924.12%4
300%231
Infinity%