npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@veloss/error

v0.0.5

Published

Handle errors in a simple and easily scalable way.

Downloads

8

Readme

@veloss/error

npm version npm downloads bundle size MIT License

간단하고 쉽게 확장 가능한 방식으로 오류를 처리 할 수 있도록 도와주는 라이브러리입니다.

Usage

Install:

# npm
npm install @veloss/error

# yarn
yarn add @veloss/error

# pnpm
pnpm add @veloss/error

Import:

// ESM / Typescript
import { BaseError, HttpError, AuthError, ... } from "@veloss/error";

// CommonJS
const { BaseError, HttpError, AuthError, ... } = require("@veloss/error");

BaseError

Base error class. This is used to create a new error class that can be extended

name

Type: string

Error name. This is used to identify the error class and should be unique among

const error = new BaseError("message");
error.name; // "BaseError"

fatal

Type: boolean

Whether the error is fatal. This is used to determine whether the process should

const error = new BaseError("message", { fatal: true });
error.fatal; // true

unhandled

Type: boolean

Whether the error is unhandled. This is used to determine whether the error was

const error = new BaseError("message", { unhandled: true });
error.unhandled; // true

data

Type: DataT

Additional data. This can be any type and is used to store any additional

const error = new BaseError("message", { data: { key: "value" } });
error.data; // { key: "value" }

cause

Type: unknown

The error that caused this error. This is used to store the error that caused

const error = new BaseError("message", { cause: new Error("cause") });
error.cause; // Error: cause

code

Type: number

Error code. This is used to store an error code and is used to identify the

const error = new BaseError("message", { code: 404 });
error.code; // 404

toJSON

Type: () => Pick<BaseError<DataT>, "message" | "data">

Converts the error to a JSON-serializable object. This is used to serialize the

const error = new BaseError("message", { data: { key: "value" } });

error.toJSON(); // { message: "message", data: { key: "value" } }

staticMethods.base_error

Type: boolean

Whether the error is a BaseError. This is used to determine whether an error

BaseError.__base_error__; // true

Basic Usage

const error = new BaseError("message");

createBaseError

CreateBaseError is a helper function that creates a new error class that extends BaseError. This is used to create a new error class that can be extended and is used to create a new error class that can be extended.

import { createBaseError } from "@veloss/error";

const error = createBaseError("CustomError");

isBaseError

isBaseError is a helper function that checks whether an error is an instance of BaseError. This is used to determine whether an error is an instance of BaseError and is used to determine whether an error is an instance of BaseError.

import { isBaseError } from "@veloss/error";

const error = new BaseError("message");

isBaseError(error); // true

HttpError

HTTP error class. BaseError is extended to create a new error class that can be extended and is used to HTTP errors.

staticMethods.http_error

Type: boolean

Whether the error is a HttpError. This is used to determine whether an error

HttpError.__http_error__; // true

statusCode

Type: number

HTTP status code. This is used to store an HTTP status code and is used to

const error = new HttpError("message", { statusCode: 404 });
error.statusCode; // 404

statusMessage

Type: string

HTTP status message. This is used to store an HTTP status message and is used to

const error = new HttpError("message", { statusMessage: "Not Found" });
error.statusMessage; // "Not Found"

Basic Usage

const error = new HttpError("message", { statusCode: 404 });

createHttpError

createHttpError is a helper function that creates a new error class that extends HttpError. This is used to create a new error class that can be extended and is used to create a new error class that can be extended.

import { createHttpError } from "@veloss/error";

const error = createHttpError("CustomHttpError", { statusCode: 404 });

isHttpError

isHttpError is a helper function that checks whether an error is an instance of HttpError. This is used to determine whether an error is an instance of HttpError and is used to determine whether an error is an instance of HttpError.

import { isHttpError } from "@veloss/error";

const error = new HttpError("message", { statusCode: 404 });

isHttpError(error); // true

AuthError

Authentication error class. BaseError is extended to create a new error class that can be extended and is used to authentication errors.

staticMethods.auth_error

Type: boolean

Whether the error is a AuthError. This is used to determine whether an error

AuthError.__auth_error__; // true

errorCode

Type: AuthErrorCode

Error code. This is used to store an error code and is used to identify the

const error = new AuthError("message", { errorCode: "unexpected_failure" });
error.errorCode; // "unexpected_failure"

statusCode

Type: number

HTTP status code. This is used to store an HTTP status code and is used to

const error = new AuthError("message", { statusCode: 404 });
error.statusCode; // 404

Basic Usage

const error = new AuthError("message", { errorCode: "unexpected_failure" });

createAuthError

createAuthError is a helper function that creates a new error class that extends AuthError. This is used to create a new error class that can be extended and is used to create a new error class that can be extended.

import { createAuthError } from "@veloss/error";

const error = createAuthError("CustomAuthError", {
  errorCode: "unexpected_failure",
});

isAuthError

isAuthError is a helper function that checks whether an error is an instance of AuthError. This is used to determine whether an error is an instance of AuthError and is used to determine whether an error is an instance of AuthError.

import { isAuthError } from "@veloss/error";

const error = new AuthError("message", { errorCode: "unexpected_failure" });

isAuthError(error); // true

License

MIT