Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

db-errors

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

db-errors

Unified node.js error API for mysql, postgres and sqlite3

  • 0.2.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is db-errors?

The db-errors npm package provides a set of custom error classes for handling database-related errors in a more structured and consistent manner. It helps developers to catch and manage different types of database errors effectively.

What are db-errors's main functionalities?

UniqueConstraintError

This feature allows you to handle unique constraint violations in your database operations. The UniqueConstraintError class can be used to catch and manage errors when a unique constraint is violated.

const { UniqueConstraintError } = require('db-errors');

try {
  // Simulate a unique constraint violation
  throw new UniqueConstraintError();
} catch (error) {
  if (error instanceof UniqueConstraintError) {
    console.error('Unique constraint violated:', error);
  }
}

ForeignKeyConstraintError

This feature allows you to handle foreign key constraint violations. The ForeignKeyConstraintError class can be used to catch and manage errors when a foreign key constraint is violated.

const { ForeignKeyConstraintError } = require('db-errors');

try {
  // Simulate a foreign key constraint violation
  throw new ForeignKeyConstraintError();
} catch (error) {
  if (error instanceof ForeignKeyConstraintError) {
    console.error('Foreign key constraint violated:', error);
  }
}

NotNullConstraintError

This feature allows you to handle not-null constraint violations. The NotNullConstraintError class can be used to catch and manage errors when a not-null constraint is violated.

const { NotNullConstraintError } = require('db-errors');

try {
  // Simulate a not-null constraint violation
  throw new NotNullConstraintError();
} catch (error) {
  if (error instanceof NotNullConstraintError) {
    console.error('Not-null constraint violated:', error);
  }
}

Other packages similar to db-errors

Keywords

FAQs

Package last updated on 31 May 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc