{"id":13847321,"url":"https://github.com/rumkin/error3","last_synced_at":"2026-03-10T11:32:38.210Z","repository":{"id":57226794,"uuid":"83170387","full_name":"rumkin/error3","owner":"rumkin","description":"💢⚠️ Error object for JS and TS","archived":false,"fork":false,"pushed_at":"2023-08-03T06:39:00.000Z","size":347,"stargazers_count":15,"open_issues_count":7,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-29T13:47:50.284Z","etag":null,"topics":["error","error-handling","error-throwing","javascript","library","nodejs","typescript"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/error3","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rumkin.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":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-02-25T23:34:42.000Z","updated_at":"2022-08-04T13:32:16.000Z","dependencies_parsed_at":"2024-01-15T20:50:26.214Z","dependency_job_id":"b2524e27-90f4-4def-bdd9-86e56f3b05f3","html_url":"https://github.com/rumkin/error3","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rumkin/error3","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rumkin%2Ferror3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rumkin%2Ferror3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rumkin%2Ferror3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rumkin%2Ferror3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rumkin","download_url":"https://codeload.github.com/rumkin/error3/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rumkin%2Ferror3/sbom","scorecard":{"id":789558,"data":{"date":"2025-08-18","repo":{"name":"github.com/rumkin/error3","commit":"f7db08371eef4950000e597624a3b8617f061d2f"},"scorecard":{"version":"v5.2.1-41-g40576783","commit":"40576783fda6698350fcbbeaea760ff827433034"},"score":1.7,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#sast"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#cii-best-practices"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#maintained"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#fuzzing"}},{"name":"License","score":9,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Warn: project license file does not contain an FSF or OSI license."],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"21 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-2j2x-2gpw-g8fm","Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-hxcc-f52p-wc94","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T07:07:27.801Z","repository_id":57226794,"created_at":"2025-08-23T07:07:27.802Z","updated_at":"2025-08-23T07:07:27.802Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30332310,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T05:25:20.737Z","status":"ssl_error","status_checked_at":"2026-03-10T05:25:17.430Z","response_time":106,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["error","error-handling","error-throwing","javascript","library","nodejs","typescript"],"created_at":"2024-08-04T18:01:16.739Z","updated_at":"2026-03-10T11:32:38.189Z","avatar_url":"https://github.com/rumkin.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg width=\"220\" alt=\"Logo with caption: proper error object\" src=\"docs/cover.png\"\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://npmjs.com/package/error3\"\u003e\n    \u003cimg alt=\"badge: npm version\" src=\"https://img.shields.io/npm/v/error3.svg?style=flat-square\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://npmjs.com/package/error3\"\u003e\n    \u003cimg alt=\"badge: npm downloads\" src=\"https://img.shields.io/npm/dw/error3.svg?style=flat-square\" /\u003e\n  \u003c/a\u003e\n  \u003cimg alt=\"badge: size 0.9 KiB\" src=\"https://img.shields.io/badge/size-0.9%20KiB-blue.svg?style=flat-square\" /\u003e\n  \u003cimg alt=\"badge: deps 0\" src=\"https://img.shields.io/badge/deps-0-blue.svg?style=flat-square\" /\u003e\n  \u003ca aria-label=\"build status\" href=\"https://travis-ci.org/rumkin/error3\"\u003e\n    \u003cimg alt=\"badge\" src=\"https://img.shields.io/travis/rumkin/error3.svg?style=flat-square\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\nError3 is an Error with extra powers. It has been designed to be extensible and easy to use.\nThough it has codes, message formatters and nested errors.\n\n* Modern: designed for TypeScript and ES2019.\n* IDE friendly: it's using classes and class fields to be inspectable for autosuggetion tools.\n* i18n ready: formatter could produce localized messages with help of [Intl API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl).\n* Easy serialization and deserealization: good for network apps and JSON logging.\n* Frontend caring: 0 dependencies, gzipped version is less then 1 KiB.\n\n## Error3 vs Error\n\n1. It's easy to compare error codes using strict equality operator. What makes error handling robust.\n2. Codes could be used as part of URL. In documentation for example.\n3. Details are stored as primitives though they could be used to produce custom output, e.g. highlighting.\n4. Error message could be localized using Intl.\n5. Error message could be modified for environment purposes.\n6. Shorten error invocation code.\n7. It's network friendly. Error could be easy restored and represented on the client side using from code and details.\n\n## Table of Contents\n\n* [Install](#install)\n* [Usage](#usage)\n* [Examples](#examples)\n* [API](#api)\n\n## Install\n\n* In node.js:\n  ```bash\n  npm i error3\n  ```\n* In browser:\n  ```html\n  \u003cscript src=\"https://unpkg.com/error3@3/dist/error3.min.js\"\u003e\u003c/script\u003e\n  ```\n  [CommonJS](https://unpkg.com/error3@3/dist/commonjs/) ·\n  [UMD](https://unpkg.com/error3@3/dist/) ·\n  [ESM](https://unpkg.com/error3@3/dist/esm/)\n  \u003e ⚠️ Remember about security! Add [subresource integrity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) (SRI) checksum\n  \u003e from [checksum.txt](https://unpkg.com/error3@3/dist/checksum.txt).\n\n## Usage\n\nError3 suppose that you will create some base error class for your application\nor library and then use it as a parent for all your errors. Watch example in\n[examples](examples) folder. Here it is interface realization:\n\n```javascript\nimport Error3 from 'error3'\n\nclass NotFoundErr extends Error3 {\n  code = 'fs_not_found'\n\n  format({ filepath }) {\n    return `File \"${filepath}\" not found`\n  }\n}\n```\n\nThis is what it gives to us:\n\n```javascript\nconst error = new NotFoundErr({ filepath: './index.js' });\n\nerror.toString() // -\u003e \"NotFoundErr: [#fs_not_found] File \"./index.js\" not found\"\nerror.message // -\u003e \"File \"./index.js\" not found\"\nerror.code // -\u003e fs_not_found\nerror.details // -\u003e {filepath: './index.js'}\n```\n\nThe same error TypeScript implementation:\n\n```typescript\nimport Error3 from 'error3'\n\nclass NotFoundErr extends Error3\u003c{ filepath: string }, void\u003e {\n  code = 'fs_not_found'\n\n  format({ filepath }): string {\n    return `File \"${filepath}\" not found`\n  }\n}\n```\n\n### JSON serialization\n\nCalling [`Error3#toJSON()`](#error3tojson) on Error3 instance returns an object with properties\n`code`, `message`, `details`, and `errors`. Example output:\n\n```json\n{\n  \"code\": \"fs_not_found\",\n  \"message\": \"File \\\"./index.js\\\" not found\",\n  \"details\": {\n    \"filepath\": \"./index.js\"\n  },\n  \"errors\": []\n}\n```\n\n## Examples\n\n* HTTP errors [JS](examples/http-errors.js) · [TS](examples/http-errors.js)\n* FileSystem errors [JS](examples/fs-errors.js) · [TS](examples/fs-errors.js)\n* Localized i18n error messages [JS](examples/intl.js) · [TS](examples/intl.js)\n\n## API\n\n### `Error3()`\n\n```text\n(details: object={}, errors: Error[]=[]) -\u003e Error3\n```\n\n__abstract__. Both of Error3 constructor arguments are optional. The resposibility of\nancestor class is to implement proper interface and pass `details` object\nand `errors` list into `super()` call. \n\n`details` is using to describe error with JS primitives. Though it could be sent\nvia network to frontend, db, or ELK without extra parsing as it should be done\nwith regular Error instance.\n\n#### TS Interface\n\n```typescript\nabstract class Error3\u003cDetails, Errors\u003e extends Error implements IError3 {\n  public readonly code: string|number\n  public readonly name: string\n  public readonly details: object\n  public readonly errors: Error[]\n\n  constructor(details: Details, errors: Errors) {}\n  abstract format(detials: Details, errors: Errors): string\n}\n```\n\n#### Example\n\n```javascript\nconst error = new UserMissed(\n  {userId: 1}, [new Error('Collection removed')]\n);\n\nerror.code // -\u003e user_missed\nerror.message // -\u003e User #1 not loaded\nerror.details // -\u003e {userId: 1}\nerror.errors // -\u003e [Error('Collection removed')]\n```\n\n### `Error#code`\n```\nstring|number\n```\n\nError code should be a string or a number. It could be defined using class fields\nsyntax:\n\n```javascript\nclass HttpNotFound extends HttpError {\n  code = 404\n}\n```\n\n### `Error3#format()`\n```\n(details: object, errors: Error[]) -\u003e string\n```\n\n__abstract__. Creates formatted message string from details and other errors.\nThis method is calling from Error3 constrcutor to define `message` property.\n\n#### JS\n```javascript\nclass PortInUse extends Error3 {\n  format({ port }) {\n    return `Port ${port} is already in use`\n  }\n}\n```\n\n#### TS\n```typescript\nclass PortInUse extends Error3\u003c{ port: string|number }, void\u003e {\n  format({ port }): string {\n    return `Port ${port} is already in use`\n  }\n}\n```\n\n### `Error3#toJSON()`\n\nWrapper of [`Error3#valueOf`](#error3valueof). It's created to be used by `JSON.stringify()`.\n\n### `Error3#valueOf()`\n```\n() -\u003e PlainError\n```\n\nThis method realizes [`Object#valueOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf) behavior and returns plain error object containing properties:\n`code`, `message`, `details` and `errors`.\n\n### `PlainError{}`\n```\n{\n  code: string|number,\n  message: string,\n  details: object,\n  errors: PlainError[],\n}\n```\n\nIt is a result of `Error3#valueOf()` call.\n\n## License\n\nMIT © [Rumkin](https://rumk.in)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frumkin%2Ferror3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frumkin%2Ferror3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frumkin%2Ferror3/lists"}