{"id":14973869,"url":"https://github.com/nihalgonsalves/pg-error-enum","last_synced_at":"2025-04-05T18:08:40.953Z","repository":{"id":34299844,"uuid":"175840437","full_name":"nihalgonsalves/pg-error-enum","owner":"nihalgonsalves","description":"TypeScript Enum for Postgres Errors with no runtime dependencies. Also compatible with plain JavaScript.","archived":false,"fork":false,"pushed_at":"2024-10-02T08:51:13.000Z","size":935,"stargazers_count":37,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-30T06:58:14.862Z","etag":null,"topics":["javascript","orm","postgres","postgresql","psql","typeorm","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/pg-error-enum","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nihalgonsalves.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-15T14:57:10.000Z","updated_at":"2024-10-02T08:51:16.000Z","dependencies_parsed_at":"2023-10-02T10:59:08.798Z","dependency_job_id":"55ac8e3a-f42c-4090-b914-fe607ae544e7","html_url":"https://github.com/nihalgonsalves/pg-error-enum","commit_stats":{"total_commits":535,"total_committers":5,"mean_commits":107.0,"dds":0.5757009345794393,"last_synced_commit":"9c61bf19f616f81c5039e56368ed4ae330fcffeb"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nihalgonsalves%2Fpg-error-enum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nihalgonsalves%2Fpg-error-enum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nihalgonsalves%2Fpg-error-enum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nihalgonsalves%2Fpg-error-enum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nihalgonsalves","download_url":"https://codeload.github.com/nihalgonsalves/pg-error-enum/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247378149,"owners_count":20929297,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","orm","postgres","postgresql","psql","typeorm","typescript"],"created_at":"2024-09-24T13:49:36.605Z","updated_at":"2025-04-05T18:08:40.937Z","avatar_url":"https://github.com/nihalgonsalves.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pg-error-enum\n\n![npm version](https://img.shields.io/npm/v/pg-error-enum.svg)\n![build status](https://github.com/nihalgonsalves/pg-error-enum/workflows/check/badge.svg)\n\nTypeScript Enum for Postgres Errors with no runtime dependencies. Also compatible with plain JavaScript.\n\n## Quick Start\n\n### Installation\n\n```sh\n# Using npm\nnpm install --save pg-error-enum\n\n# Using yarn\nyarn add pg-error-enum\n```\n\n### Usage\n\n```ts\nimport { PostgresError } from \"pg-error-enum\";\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eLegacy CommonJS\u003c/summary\u003e\n\n```js\nconst { PostgresError } = require(\"pg-error-enum\");\n```\n\n\u003c/details\u003e\n\nUsage\n\n```ts\nif (error.code === PostgresError.UNIQUE_VIOLATION) {\n  throw new Error(\"That username is taken\");\n}\n```\n\n## Generation\n\nThe Enum is generated directly from [errcodes.txt](https://github.com/postgres/postgres/blob/master/src/backend/utils/errcodes.txt) in the Postgres repository.\n\nIt follows the syntax defined in the text file, i.e., in short:\n\n1. Lines beginning with `#` and empty lines are ignored.\n\n2. Sections are parsed using:\n\n   ```ts\n   const sectionRegex = /^Section:\\s(?\u003cdescription\u003e.*)$/;\n   ```\n\n3. Each error code is parsed using:\n\n   ```ts\n   const errorLineRegex =\n     /^(?\u003csqlstate\u003e[A-Z0-9]*)\\s*(?\u003cseverity\u003e[EWS])\\s*ERRCODE_(?\u003cconstant\u003e[A-Z_]*)\\s*(?\u003ccode\u003e[a-z_]*)$/;\n   ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnihalgonsalves%2Fpg-error-enum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnihalgonsalves%2Fpg-error-enum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnihalgonsalves%2Fpg-error-enum/lists"}