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

@prisma-next/sql-errors

v0.4.1

Published

Normalized SQL driver error types for Prisma Next

Readme

@prisma-next/sql-errors

SQL-normalized driver error types for Prisma Next.

Package Classification

  • Domain: sql
  • Layer: core
  • Plane: shared

Overview

This package provides normalized error classes for SQL driver errors. These errors are shared across both migration-plane and runtime-plane code, allowing consistent error handling regardless of which driver is being used.

Purpose

Normalize driver-specific errors (e.g., Postgres pg errors) into well-typed, SQL-family error classes that can be handled deterministically by migration runners, CLI commands, and other downstream systems.

Responsibilities

  • Error Types: Define SqlQueryError and SqlConnectionError classes
  • Type Predicates: Provide .is() methods for safe error checking without instanceof
  • Stack Trace Preservation: Preserve original error stack traces via ES2022 Error.cause

Error Classes

SqlQueryError

Represents query-related failures:

  • Syntax errors
  • Constraint violations
  • Permission errors
  • Other SQL execution errors

Fields:

  • kind: 'sql_query' (discriminator)
  • sqlState: Postgres SQLSTATE code (e.g., '23505')
  • constraint: Constraint name if applicable
  • table: Table name if applicable
  • column: Column name if applicable
  • detail: Additional detail from database

SqlConnectionError

Represents connection-related failures:

  • Connection timeouts
  • Connection resets
  • Connection refused
  • Other connectivity issues

Fields:

  • kind: 'sql_connection' (discriminator)
  • transient: Whether retry might succeed

Usage

import { SqlQueryError, SqlConnectionError } from '@prisma-next/sql-errors';

// Check error type using type predicate (recommended)
if (SqlQueryError.is(error)) {
  console.log('SQLSTATE:', error.sqlState);
  console.log('Constraint:', error.constraint);
  console.log('Original stack:', error.cause?.stack);
}

// Create normalized error with original error preserved
const normalized = new SqlQueryError('Query failed', {
  cause: originalError,
  sqlState: '23505',
  constraint: 'user_email_unique',
});

Architecture

This package is in the shared plane, meaning it can be imported by both migration-plane and runtime-plane packages. This allows drivers (runtime plane) and migration runners (migration plane) to use the same error types.

Related Documentation

  • docs/architecture docs/subsystems/5. Adapters & Targets.md: Driver architecture
  • docs/Error Handling.md: Error handling patterns