{"versions":{"0.2.3":{"name":"db-errors","version":"0.2.3","description":"Unified node.js error API for mysql, postgres and sqlite3","main":"lib/dbErrors.js","scripts":{"test":"mocha --slow 10 --timeout 15000 --reporter spec --recursive tests","test-travis":"mocha --slow 10 --timeout 15000 --reporter spec --recursive tests"},"repository":{"type":"git","url":"git+ssh://git@github.com/Vincit/db-errors.git"},"keywords":["mysql","postgres","postgresql","sqlite3","error","errors","error","handling","error","handler"],"author":{"name":"Sami Koskimäki","email":"sami@jakso.me","url":"https://github.com/koskimas"},"license":"MIT","bugs":{"url":"https://github.com/Vincit/db-errors/issues"},"homepage":"https://github.com/Vincit/db-errors#readme","devDependencies":{"bluebird":"^3.5.3","expect.js":"^0.3.1","knex":"^0.14.6","lodash":"^4.17.11","mocha":"^5.2.0","mssql":"^5.0.3","mysql":"^2.16.0","mysql2":"^1.6.4","pg":"^7.7.1","sqlite3":"^4.0.4"},"gitHead":"6ed1975c135484e127643250e1e64b2bd8fc35a8","_id":"db-errors@0.2.3","_npmVersion":"6.4.1","_nodeVersion":"10.10.0","_npmUser":{"name":"anonymous","email":"koskomi@gmail.com"},"dist":{"shasum":"a6a38952e00b20e790f2695a6446b3c65497ffa2","size":14301,"noattachment":false,"tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/db-errors/-/db-errors-0.2.3.tgz","integrity":"sha512-OOgqgDuCavHXjYSJoV2yGhv6SeG8nk42aoCSoyXLZUH7VwFG27rxbavU1z+VrZbZjphw5UkDQwUlD21MwZpUng=="},"maintainers":[{"name":"anonymous","email":"koskomi@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/db-errors_0.2.3_1559296495418_0.33306806322134275"},"_hasShrinkwrap":false,"publish_time":1559296495548,"_cnpm_publish_time":1559296495548,"_cnpmcore_publish_time":"2021-12-16T18:30:18.034Z","contributors":[]},"0.2.2":{"name":"db-errors","version":"0.2.2","description":"Unified node.js error API for mysql, postgres and sqlite3","main":"lib/dbErrors.js","scripts":{"test":"mocha --slow 10 --timeout 15000 --reporter spec --recursive tests","test-travis":"mocha --slow 10 --timeout 15000 --reporter spec --recursive tests"},"repository":{"type":"git","url":"git+ssh://git@github.com/Vincit/db-errors.git"},"keywords":["mysql","postgres","postgresql","sqlite3","error","errors","error","handling","error","handler"],"author":{"name":"Sami Koskimäki","email":"sami@jakso.me","url":"https://github.com/koskimas"},"license":"MIT","bugs":{"url":"https://github.com/Vincit/db-errors/issues"},"homepage":"https://github.com/Vincit/db-errors#readme","devDependencies":{"bluebird":"^3.5.3","expect.js":"^0.3.1","knex":"^0.14.6","lodash":"^4.17.11","mocha":"^5.2.0","mssql":"^5.0.3","mysql":"^2.16.0","mysql2":"^1.6.4","pg":"^7.7.1","sqlite3":"^4.0.4"},"gitHead":"d01d36ba1ab21f58b55a72a9fed759999f14db41","_id":"db-errors@0.2.2","_nodeVersion":"11.13.0","_npmVersion":"6.7.0","dist":{"shasum":"26a5cb7ac26486ef2e7c802eaaffb44d50d8d264","size":14289,"noattachment":false,"tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/db-errors/-/db-errors-0.2.2.tgz","integrity":"sha512-zohLo8J6p3pcGF3x+24K3S2iyUU9zGX8jr/TiplvmlOsjdoqNd4/g7Ew7u1fCtFQAJU+o1faGpCftQ7GHvDwTA=="},"maintainers":[{"name":"anonymous","email":"koskomi@gmail.com"}],"_npmUser":{"name":"anonymous","email":"koskomi@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/db-errors_0.2.2_1554718043578_0.49647039334814713"},"_hasShrinkwrap":false,"publish_time":1554718043743,"_cnpm_publish_time":1554718043743,"_cnpmcore_publish_time":"2021-12-16T18:30:18.309Z","contributors":[]},"0.2.1":{"name":"db-errors","version":"0.2.1","description":"Unified node.js error API for mysql, postgres and sqlite3","main":"lib/dbErrors.js","scripts":{"test":"mocha --slow 10 --timeout 15000 --reporter spec --recursive tests","test-travis":"mocha --slow 10 --timeout 15000 --reporter spec --recursive tests"},"repository":{"type":"git","url":"git+ssh://git@github.com/Vincit/db-errors.git"},"keywords":["mysql","postgres","postgresql","sqlite3","error","errors","error","handling","error","handler"],"author":{"name":"Sami Koskimäki","email":"sami@jakso.me","url":"https://github.com/koskimas"},"license":"MIT","bugs":{"url":"https://github.com/Vincit/db-errors/issues"},"homepage":"https://github.com/Vincit/db-errors#readme","devDependencies":{"bluebird":"^3.5.3","expect.js":"^0.3.1","knex":"^0.14.6","lodash":"^4.17.11","mocha":"^5.2.0","mssql":"^5.0.3","mysql":"^2.16.0","mysql2":"^1.6.4","pg":"^7.7.1","sqlite3":"^4.0.4"},"gitHead":"83e8414e94a9242c1e9d3a3ec6ca8cd619769d81","_id":"db-errors@0.2.1","_npmVersion":"6.5.0-next.0","_nodeVersion":"11.6.0","_npmUser":{"name":"anonymous","email":"koskomi@gmail.com"},"dist":{"shasum":"adf558738a518f0854057620390f2c8fb85ddf81","size":14290,"noattachment":false,"tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/db-errors/-/db-errors-0.2.1.tgz","integrity":"sha512-mzKE2fX+zzEJ8JFuUqZX0DnoZ7A5Xq1HI8SaKf6mHCz+96bbAIKKn0GdfNt2RAyReA3A3ZA9fVjE+B8HJMhu3g=="},"maintainers":[{"name":"anonymous","email":"koskomi@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/db-errors_0.2.1_1554446277631_0.7438370550649562"},"_hasShrinkwrap":false,"publish_time":1554446277808,"_cnpm_publish_time":1554446277808,"_cnpmcore_publish_time":"2021-12-16T18:30:18.541Z","contributors":[]},"0.2.0":{"name":"db-errors","version":"0.2.0","description":"Unified node.js error API for mysql, postgres and sqlite3","main":"lib/dbErrors.js","scripts":{"test":"mocha --slow 10 --timeout 15000 --reporter spec --recursive tests","test-travis":"mocha --slow 10 --timeout 15000 --reporter spec --recursive tests"},"repository":{"type":"git","url":"git+ssh://git@github.com/Vincit/db-errors.git"},"keywords":["mysql","postgres","postgresql","sqlite3","error","errors","error","handling","error","handler"],"author":{"name":"Sami Koskimäki","email":"sami@jakso.me","url":"https://github.com/koskimas"},"license":"MIT","bugs":{"url":"https://github.com/Vincit/db-errors/issues"},"homepage":"https://github.com/Vincit/db-errors#readme","devDependencies":{"bluebird":"^3.5.3","expect.js":"^0.3.1","knex":"^0.14.6","lodash":"^4.17.11","mocha":"^5.2.0","mssql":"^5.0.3","mysql":"^2.16.0","mysql2":"^1.6.4","pg":"^7.7.1","sqlite3":"^4.0.4"},"gitHead":"af208746c5453213c0343e7b22c8d7cadab5910b","_id":"db-errors@0.2.0","_npmVersion":"6.5.0-next.0","_nodeVersion":"11.6.0","_npmUser":{"name":"anonymous","email":"koskomi@gmail.com"},"dist":{"shasum":"b3c7a16fb860023a094ddc5918002981b2fb505e","size":14350,"noattachment":false,"tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/db-errors/-/db-errors-0.2.0.tgz","integrity":"sha512-HF/V6T/+BsbXAqUEkqMCw+S3voDo7gaI12wIQhQdblfe8K1qmzhpnvDZz7N85pqV3IgwQM4wUokZMiy+MSfofA=="},"maintainers":[{"name":"anonymous","email":"koskomi@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/db-errors_0.2.0_1554409707655_0.38837397638637583"},"_hasShrinkwrap":false,"publish_time":1554409707782,"_cnpm_publish_time":1554409707782,"_cnpmcore_publish_time":"2021-12-16T18:30:18.751Z","contributors":[]},"0.1.1":{"name":"db-errors","version":"0.1.1","description":"Unified node.js error API for mysql, postgres and sqlite3","main":"lib/dbErrors.js","scripts":{"test":"mocha --slow 10 --timeout 15000 --reporter spec --recursive tests","test-travis":"mocha --slow 10 --timeout 15000 --reporter spec --recursive tests"},"repository":{"type":"git","url":"git+ssh://git@github.com/Vincit/db-errors.git"},"keywords":["mysql","postgres","postgresql","sqlite3","error","errors","error","handling","error","handler"],"author":{"name":"Sami Koskimäki","email":"sami.koskimaki@vincit.com","url":"https://github.com/koskimas"},"license":"MIT","bugs":{"url":"https://github.com/Vincit/db-errors/issues"},"homepage":"https://github.com/Vincit/db-errors#readme","devDependencies":{"bluebird":"^3.5.3","expect.js":"^0.3.1","knex":"^0.14.6","lodash":"^4.17.11","mocha":"^5.2.0","mysql":"^2.16.0","mysql2":"^1.6.4","pg":"^7.7.1","sqlite3":"^4.0.4"},"gitHead":"3845c3ebfca437e4ee8d375c3f193ba40b3d2667","_id":"db-errors@0.1.1","_npmVersion":"6.5.0-next.0","_nodeVersion":"11.6.0","_npmUser":{"name":"anonymous","email":"koskomi@gmail.com"},"dist":{"shasum":"7fed5164f7822135ba655c73ed4f32277964920d","size":12717,"noattachment":false,"tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/db-errors/-/db-errors-0.1.1.tgz","integrity":"sha512-/yyJI6OAZg/KPBfG9TMgqV9m8W79XjkfZk++wChdeWxkwn3BvV5d6+aEkO8flh/tHMnasZ5k36bjliHuqHvFyw=="},"maintainers":[{"name":"anonymous","email":"koskomi@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/db-errors_0.1.1_1546093183453_0.10261568740751548"},"_hasShrinkwrap":false,"publish_time":1546093183616,"_cnpm_publish_time":1546093183616,"_cnpmcore_publish_time":"2021-12-16T18:30:18.969Z","contributors":[]},"0.1.0":{"name":"db-errors","version":"0.1.0","description":"Unified node.js error API for mysql, postgres and sqlite3","main":"lib/dbErrors.js","scripts":{"test":"mocha --slow 10 --timeout 15000 --reporter spec --recursive tests","test-travis":"mocha --slow 10 --timeout 15000 --reporter spec --recursive tests"},"repository":{"type":"git","url":"git+ssh://git@github.com/Vincit/db-errors.git"},"keywords":["mysql","postgres","postgresql","sqlite3","error","errors","error","handling","error","handler"],"author":{"name":"Sami Koskimäki","email":"sami.koskimaki@vincit.com","url":"https://github.com/koskimas"},"license":"MIT","bugs":{"url":"https://github.com/Vincit/db-errors/issues"},"files":["README.md","LICENSE","lib/*"],"homepage":"https://github.com/Vincit/db-errors#readme","devDependencies":{"bluebird":"^3.5.0","expect.js":"^0.3.1","knex":"^0.13.0","lodash":"^4.17.4","mocha":"^3.5.3","mysql":"^2.14.1","mysql2":"^1.4.2","pg":"^7.3.0","sqlite3":"^3.1.11"},"gitHead":"a98347a23be63770a44385a2c4c3cfbe15be4c73","_id":"db-errors@0.1.0","_npmVersion":"5.5.1","_nodeVersion":"8.9.0","_npmUser":{"name":"anonymous","email":"sami.koskimaki@vincit.com"},"dist":{"shasum":"e3706bb988c7093c522141dcd1457a3aa5e01a54","size":12483,"noattachment":false,"tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/db-errors/-/db-errors-0.1.0.tgz","integrity":"sha512-EDsvJTkULFjWE6gJ9zwnh6vf/r2z3mm9g97WI3d6uyFMo0Cldd/ihWBnPYpiBopMnANegMLdeIpg8NLQZLcXPw=="},"maintainers":[{"name":"anonymous","email":"koskomi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/db-errors-0.1.0.tgz_1512363127663_0.3795902272686362"},"directories":{},"publish_time":1512363127779,"_hasShrinkwrap":false,"_cnpm_publish_time":1512363127779,"_cnpmcore_publish_time":"2021-12-16T18:30:19.176Z","contributors":[]}},"dist-tags":{"latest":"0.2.3"},"name":"db-errors","time":{"created":"2022-01-26T21:09:47.572Z","modified":"2022-01-26T21:09:47.572Z","0.2.3":"2019-05-31T09:54:55.548Z","0.2.2":"2019-04-08T10:07:23.743Z","0.2.1":"2019-04-05T06:37:57.808Z","0.2.0":"2019-04-04T20:28:27.782Z","0.1.1":"2018-12-29T14:19:43.616Z","0.1.0":"2017-12-04T04:52:07.779Z"},"readme":"[![Build Status](https://travis-ci.org/Vincit/db-errors.svg?branch=master)](https://travis-ci.org/Vincit/db-errors)\n\n# Unified error API for node.js SQL DB drivers\n\nThis project is an attempt to create a unified API for node.js SQL DB driver errors. Each driver\nthrows their own kind of errors and libraries like knex, Bookshelf and objection.js simply\npass these errors through. It's usually very difficult to reason with these errors. This\nlibrary wraps those errors to error classes that are the same for all drivers. The wrapped\nerror classes also expose useful information about the errors.\n\n__NOTE__: Only MySQL, Sqlite3, MSSQL and PostgreSQL are officially supported (tested).\n\n# Contributions and suggestions are most welcome\n\nIf you have an idea for an error we should handle, please open an issue and we'll see what we can do to add it.\n\n<br>\n<br>\n\n## Usage\n\n```js\nconst {\n  wrapError,\n  DBError,\n  UniqueViolationError,\n  NotNullViolationError\n} = require('db-errors');\n\nfunction errorHandler(err) {\n  // wrapError function takes any error and returns a DBError subclass instance if\n  // the input was an error thrown by the supported database drivers. Otherwise\n  // the input error is returned.\n  err = wrapError(err);\n\n  if (err instanceof UniqueViolationError) {\n    console.log(`Unique constraint ${err.constraint} failed for table ${err.table} and columns ${err.columns}`);\n  } else if (err instanceof NotNullViolationError) {\n    console.log(`Not null constraint failed for table ${err.table} and column ${err.column}`);\n  } else if (err instanceof DBError) {\n    console.log(`Some unknown DB error ${dbError.nativeError}`);\n  }\n}\n```\n\n<br>\n<br>\n\n## API\n\n<br>\n<br>\n\n### DBError\n\n```ts\nclass DBError extends Error {\n  // The error thrown by the database client.\n  nativeError: Error\n}\n```\n\nBase class for all errors.\n\n<br>\n<br>\n\n### ConstraintViolationError\n\n```ts\nclass ConstraintViolationError extends DBError {\n  // No own properties.\n}\n```\n\nA base class for all constraint violation errors\n\n<br>\n<br>\n\n### UniqueViolationError\n\n```ts\nclass UniqueViolationError extends ConstraintViolationError {\n  // The columns that failed.\n  //\n  // Available for: postgres, sqlite\n  columns: string[]\n\n  // The table that has the columns.\n  //\n  // Available for: postgres, sqlite\n  table: string\n\n  // The constraint that was violated.\n  //\n  // Available for: postgres, mysql\n  constraint: string\n}\n```\n\n<br>\n<br>\n\n### NotNullViolationError\n\n```ts\nclass NotNullViolationError extends ConstraintViolationError {\n  // The column that failed.\n  //\n  // Available for: postgres, sqlite, mysql\n  column: string\n\n  // The table that has the columns.\n  //\n  // Available for: postgres, sqlite\n  table: string\n}\n```\n\n<br>\n<br>\n\n### ForeignKeyViolationError\n\n```ts\nclass ForeignKeyViolationError extends ConstraintViolationError {\n  // The table that has the foreign key.\n  //\n  // Available for: postgres, mysql\n  table: string\n\n  // The constraint that was violated.\n  //\n  // Available for: postgres, mysql\n  constraint: string\n}\n```\n\n<br>\n<br>\n\n### CheckViolationError\n\n```ts\n// This is not available for MySql since MySql doesn't have check constraints.\nclass CheckViolationError extends ConstraintViolationError {\n  // The table that has the check constraint.\n  //\n  // Available for: postgres\n  table: string\n\n  // The constraint that was violated.\n  //\n  // Available for: postgres\n  constraint: string\n}\n```\n\n<br>\n<br>\n\n### DataError\n\n```ts\n// Invalid data (string too long, invalid date etc.)\n//\n// NOTE: SQLite uses dynamic typing and doesn't throw this error.\nclass DataError extends DBError {\n  // There is no easy way to parse data from these kind\n  // of errors.\n}\n```\n\n<br>\n<br>\n\n\n## Development setup\n\nRun the following commands in the repo root:\n\n```shell\ndocker-compose up\nnode setup-test-db.js\n```\n\nRun tests:\n\n```shell\nnpm test\n```","users":{}}