{"id":19930667,"url":"https://github.com/muffoi/error-editor","last_synced_at":"2026-04-21T13:03:15.426Z","repository":{"id":185258521,"uuid":"673238189","full_name":"muffoi/error-editor","owner":"muffoi","description":"Catches errors, allows edits of them and throws errors again.","archived":false,"fork":false,"pushed_at":"2023-08-11T21:37:16.000Z","size":14,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-01T11:24:58.851Z","etag":null,"topics":["edit","error","error-handling","errors","javascript","npm","try-catch"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/error-editor","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/muffoi.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2023-08-01T07:22:23.000Z","updated_at":"2024-09-14T09:47:46.000Z","dependencies_parsed_at":"2023-08-01T09:08:24.045Z","dependency_job_id":null,"html_url":"https://github.com/muffoi/error-editor","commit_stats":null,"previous_names":["muffoi/error-editor"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/muffoi/error-editor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muffoi%2Ferror-editor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muffoi%2Ferror-editor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muffoi%2Ferror-editor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muffoi%2Ferror-editor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/muffoi","download_url":"https://codeload.github.com/muffoi/error-editor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muffoi%2Ferror-editor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32093156,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-21T11:25:29.218Z","status":"ssl_error","status_checked_at":"2026-04-21T11:25:28.499Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["edit","error","error-handling","errors","javascript","npm","try-catch"],"created_at":"2024-11-12T23:04:52.618Z","updated_at":"2026-04-21T13:03:15.370Z","avatar_url":"https://github.com/muffoi.png","language":"JavaScript","readme":"# error-editor ![NPM Package Version](https://img.shields.io/npm/v/error-editor?style=flat-square\u0026link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2Ferror-editor)\nError-Editor is a zero-dependency module that catches errors from functions and promises, allows edits of errors, and throws caught errors again.  \n![License](https://img.shields.io/github/license/muffoi/error-editor)\n\u003c!-- ![Downloads](https://img.shields.io/npm/dt/error-editor) --\u003e\n\n\u003ch2 id=\"install\"\u003eInstallation\u003c/h2\u003e\n\nThrough NPM:\n```bash\nnpm install error-editor\n```\n\n\n\n\u003ch2 id=\"use\"\u003eUsage\u003c/h2\u003e\n\nRequire with CommonJS:\n```javascript\nconst errorEditor = require(\"error-editor\");\n```\nOr with ES6 `import`:\n```javascript\nimport * as errorEditor from \"error-editor\";\n```\n\n\n\n\u003ch2 id=\"docs\"\u003eDocumentation\u003c/h2\u003e\n\n- [`errorEditor.catchError()`](#ee-ce)\n- [`errorEditor.catchErrorSync()`](#ee-ces)\n- [class `errorEditor.CaughtError`](#ce)\n    - [`CaughtError` constructor](#ce-const)\n    - [`CaughtError.message`](#ce-msg)\n    - [`CaughtError.constr`](#ce-constr)\n    - [`CaughtError.throw()`](#ce-throw)\n- [`errorEditor.version`](#ee-ver)\n\n\n\u003ch3 id=\"ee-ce\"\u003e\u003ccode\u003eerrorEditor.catchError(value, ...params)\u003c/code\u003e \u003csmall\u003e\u003ci\u003efrom \u003ccode\u003ev1.0.0\u003c/code\u003e\u003c/i\u003e\u003c/small\u003e\u003c/h3\u003e\n\n**Parameters:**  \n- `value: Function|Promise|PromiseLike` - A *function* or a *promise* to catch error from.\n- `params: any[]` - Parameters to pass into `value` when called (if `value` is a *function*). *Optional.*\n\nCatches an error from `value` parameter and returns a *promise* that resolves to it's [`CaughtError`](#ce) form, if no error occurs, *promise* resolves to `value`'s return/resolve value.  \nIf the `value` argument is not a function or a \u003ca href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#thenables\" target=\"_blank\"\u003ethenable\u003c/a\u003e, a `TypeError` will be thrown.\n\n***Note:** `throw` statements that are not called with, and `Promise` rejects with something else than an `Error` or its child are considered as `Error` object with `message` set to that value.*\n\n**Usage:**\n```javascript\nlet foo = async (x = \"world\") =\u003e `Hello, ${x}!`;\n\nlet value = await errorEditor.catchError(foo);\nvalue; // \"Hello, world!\"\n\n\nlet bar = (x = \"world\") =\u003e `Hello, ${x}!`;\n\nlet value2 = await errorEditor.catchError(foo, \"user\");\nvalue2; // \"Hello, user!\"\n\n\nlet baz = Promise.reject(\"Error appeared!\");\n\nlet err = await errorEditor.catchError(baz);\nerr; // CaughtError {constr: Error, message: \"Error appeared!\"}\n```\n\n\n\u003ch3 id=\"ee-ces\"\u003e\u003ccode\u003eerrorEditor.catchErrorSync(value, ...params)\u003c/code\u003e \u003csmall\u003e\u003ci\u003efrom \u003ccode\u003ev1.0.0\u003c/code\u003e\u003c/i\u003e\u003c/small\u003e\u003c/h3\u003e\n\n**Parameters:**  \n- `value: Function` - A *function* to catch error from. **Warning: Async functions not supported.** \n- `params: any[]` - Parameters to pass into `value` when called. *Optional.*\n\nCatches an error from `value` parameter and returns it's [`CaughtError`](#ce) form, if no error occurs, returns `value`'s return value. *[`errorEditor.catchError()`](#ee-ce)'s sync version.*  \nIf the `value` argument is not a function, a `TypeError` will be thrown.  \n**Usage:**\n```javascript\nlet foo = (x = \"world\") =\u003e `Hello, ${x}!`;\n\nlet value = errorEditor.catchErrorSync(foo);\nvalue; // \"Hello, world!\"\n\n\nlet bar = (x = \"world\") =\u003e `Hello, ${x}!`;\n\nlet value2 = errorEditor.catchErrorSync(foo, \"user\");\nvalue2; // \"Hello, user!\"\n\n\nlet baz = () =\u003e {\n    throw new Error(\"Error appeared!\");\n};\n\nlet err = errorEditor.catchErrorSync(baz);\nerr; // CaughtError {constr: Error, message: \"Error appeared!\"}\n```\n\n\n\u003ch3 id=\"ce\"\u003eclass \u003ccode\u003eerrorEditor.CaughtError\u003c/code\u003e \u003csmall\u003e\u003ci\u003efrom \u003ccode\u003ev1.0.0\u003c/code\u003e\u003c/i\u003e\u003c/small\u003e\u003c/h3\u003e\n\u003ch3 id=\"ce-const\"\u003eclass constructor\u003c/h3\u003e\n\n**Parameters:**\n- `message: string|void` - Error's `message` property. *Defaults to `\"\"` (empty string).*\n- `constr: NewableFunction|void` - Error's constructor. *Defaults to `Error`.*\n\nIf constructing new `constr` throws an error, the `Error` constructor will be saved to object.\n\n\u003ch3 id=\"ce-msg\"\u003e\u003ccode\u003eCaughtError.message\u003c/code\u003e \u003csmall\u003e\u003ci\u003efrom \u003ccode\u003ev1.0.0\u003c/code\u003e\u003c/i\u003e\u003c/small\u003e\u003c/h3\u003e\n\nError message used to construct the error. *Editable.*\n\n\n\u003ch3 id=\"ce-constr\"\u003e\u003ccode\u003eCaughtError.constr\u003c/code\u003e \u003csmall\u003e\u003ci\u003efrom \u003ccode\u003ev1.0.0\u003c/code\u003e\u003c/i\u003e\u003c/small\u003e\u003c/h3\u003e\n\nError constructor used to construct the error. *Editable.*\n\n\n\u003ch3 id=\"ce-throw\"\u003e\u003ccode\u003eCaughtError.throw()\u003c/code\u003e \u003csmall\u003e\u003ci\u003efrom \u003ccode\u003ev1.0.0\u003c/code\u003e\u003c/i\u003e\u003c/small\u003e\u003c/h3\u003e\n\nThrows an error based on instance's properties. The `message` property will be stringified.  \nIf constructing new `constr` throws an error, the `Error` constructor will be used.\n\n\u003ch3 id=\"ee-ver\"\u003e\u003ccode\u003eerrorEditor.version\u003c/code\u003e \u003csmall\u003e\u003ci\u003efrom \u003ccode\u003ev1.0.0\u003c/code\u003e\u003c/i\u003e\u003c/small\u003e\u003c/h3\u003e\n\nContains `error-editor` package version info. *Read-only.*\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuffoi%2Ferror-editor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmuffoi%2Ferror-editor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuffoi%2Ferror-editor/lists"}