Unified error API for node.js SQL database drivers (MySQL, PostgreSQL, SQLite3, MSSQL). Current stable version 0.2.3. This library normalizes driver-specific errors (like unique constraint violations, not-null violations) into standard error classes, providing consistent properties such as table name, column name, and constraint name across databases. It is in early stages (pre-1.0) with limited active development, but is widely used as a dependency in ORMs like objection.js. Alternative error handling is driver-specific; this library simplifies error handling.
npm install db-errorsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Wraps a native database driver error into a unified error class and handles specific violations.
Ensure your database driver is one of the supported ones, or check if the returned error is an instance of DBError before using driver-specific properties.
Always check if the property exists (e.g., if (err.columns) ...) or refer to the documentation for driver-specific availability.
Handle SQLite errors separately or use the base DBError for fallback.
Use destructured import: import { wrapError } from 'db-errors'Use type assertion: (err as any).columns or install type definitions from DefinitelyTyped if available.
No dependency data recorded yet.
No traffic data recorded yet.