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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@nice-code/common-errors

v0.86.0

Published

Readme

@nice-code/common-errors

Docs: nicecode.io — guides, integrations, and the full API surface. Working with an AI assistant? Point it at nicecode.io/llms-common-errors.txt (just this package) or nicecode.io/llms.txt (the whole stack) — the complete, current docs flattened into plain text.

Shared error domains for Standard Schema validation errors, with Hono middleware integration.

Install

bun add @nice-code/common-errors

Peer deps: valibot (or any Standard Schema library), hono (for /hono subpath).


Validation error domain

err_validation is a @nice-code/error domain for Standard Schema validation failures. Import it to match or inspect validation errors by domain.

import { err_validation, EValidator } from "@nice-code/common-errors";

// Check if an error is a validation error
if (err_validation.isExact(caught)) {
  const hydrated = err_validation.hydrate(caught);
  const { issues } = hydrated.getContext(EValidator.standard_schema);
  // issues: readonly StandardSchemaV1.Issue[]
}

The domain exposes one error id: EValidator.standard_schema with context { issues }.


Hono middleware

Import from the /hono subpath:

import { niceSValidator, niceCatchSValidation } from "@nice-code/common-errors/hono";

niceSValidator(target, schema)

Drop-in replacement for @hono/standard-validator's sValidator that throws a NiceError instead of returning a 400 response when validation fails.

import { niceSValidator } from "@nice-code/common-errors/hono";
import * as v from "valibot";

const CreateUserSchema = v.object({
  name: v.string(),
  email: v.pipe(v.string(), v.email()),
});

app.post("/users", niceSValidator("json", CreateUserSchema), async (c) => {
  const body = c.req.valid("json"); // fully typed
  // ...
});

When validation fails, a NiceError from the err_validation domain is thrown. Use Hono's onError handler to convert it to a JSON response:

import { castNiceError } from "@nice-code/error";

app.onError((err, c) => {
  const niceError = castNiceError(err);
  return c.json(niceError.toJsonObject(), niceError.httpStatusCode as any);
});

niceCatchSValidation()

Middleware that intercepts raw @hono/standard-validator validation responses (the default { success: false, error: [...] } shape) and converts them into NiceError JSON responses. Use this when you can't replace sValidator with niceSValidator directly.

app.use(niceCatchSValidation());

// Existing sValidator usage is automatically intercepted
app.post("/data", sValidator("json", MySchema), handler);

Full Hono example

import { Hono } from "hono";
import { niceSValidator } from "@nice-code/common-errors/hono";
import { castNiceError, EErrorPackType } from "@nice-code/error";
import * as v from "valibot";

const app = new Hono();

app.onError((err, c) => {
  const niceError = castNiceError(err);
  return c.json(niceError.toJsonObject(), niceError.httpStatusCode as any);
});

const BodySchema = v.object({ message: v.string() });

app.post("/echo", niceSValidator("json", BodySchema), async (c) => {
  const { message } = c.req.valid("json");
  return c.json({ echo: message });
});