{"id":17398476,"url":"https://github.com/vweevers/maybe-combine-errors","last_synced_at":"2025-10-14T17:45:37.713Z","repository":{"id":57292826,"uuid":"281914693","full_name":"vweevers/maybe-combine-errors","owner":"vweevers","description":"Combine 0 or more errors into one.","archived":false,"fork":false,"pushed_at":"2020-07-23T09:58:24.000Z","size":3,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-05T05:47:53.066Z","etag":null,"topics":["errors","nodejs","npm-package"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/vweevers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-23T09:56:16.000Z","updated_at":"2022-07-06T23:34:19.000Z","dependencies_parsed_at":"2022-08-27T12:21:07.059Z","dependency_job_id":null,"html_url":"https://github.com/vweevers/maybe-combine-errors","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/vweevers/maybe-combine-errors","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fmaybe-combine-errors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fmaybe-combine-errors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fmaybe-combine-errors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fmaybe-combine-errors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vweevers","download_url":"https://codeload.github.com/vweevers/maybe-combine-errors/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fmaybe-combine-errors/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279020045,"owners_count":26086806,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["errors","nodejs","npm-package"],"created_at":"2024-10-16T14:57:08.970Z","updated_at":"2025-10-14T17:45:37.697Z","avatar_url":"https://github.com/vweevers.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# maybe-combine-errors\n\n**Combine 0 or more errors into one.**\n\n[![npm status](http://img.shields.io/npm/v/maybe-combine-errors.svg)](https://www.npmjs.org/package/maybe-combine-errors)\n[![node](https://img.shields.io/node/v/maybe-combine-errors.svg)](https://www.npmjs.org/package/maybe-combine-errors)\n[![Travis build status](https://img.shields.io/travis/com/vweevers/maybe-combine-errors.svg?label=travis)](http://travis-ci.com/vweevers/maybe-combine-errors)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n## Usage\n\n```js\nconst combine = require('maybe-combine-errors')\n\nconst err1 = new Error('one')\nconst err2 = new Error('two')\n\nconsole.log(combine([err1, err2]).message)\nconsole.log(combine([err1, err2]) instanceof Error)\nconsole.log(combine([err1, null]) === err1)\nconsole.log(combine([]) === undefined)\n\nthrow combine([err1, err2])\n```\n\n```\n$ node example.js\none; two\ntrue\ntrue\ntrue\nexample.js:9\nthrow combine([err1, err2])\n^\n\nError: one\n    at Object.\u003canonymous\u003e (example.js:3:14)\n    at Module._compile (internal/modules/cjs/loader.js:945:30)\n    at Object.Module._extensions..js (internal/modules/cjs/loader.js:962:10)\n    at Module.load (internal/modules/cjs/loader.js:798:32)\n    at Function.Module._load (internal/modules/cjs/loader.js:711:12)\n    at Function.Module.runMain (internal/modules/cjs/loader.js:1014:10)\n    at internal/main/run_main_module.js:17:11\n\nError: two\n    at Object.\u003canonymous\u003e (example.js:4:14)\n    at Module._compile (internal/modules/cjs/loader.js:945:30)\n    at Object.Module._extensions..js (internal/modules/cjs/loader.js:962:10)\n    at Module.load (internal/modules/cjs/loader.js:798:32)\n    at Function.Module._load (internal/modules/cjs/loader.js:711:12)\n    at Function.Module.runMain (internal/modules/cjs/loader.js:1014:10)\n    at internal/main/run_main_module.js:17:11\n```\n\n## API\n\n### `combine(errors)`\n\nThe `errors` argument must be an array.\n\nElements that are `null` or `undefined` are skipped. If the array is empty (after skipping `null` and `undefined`), `undefined` will be returned. If the array contains only 1 error, that error will be returned as-is. Otherwise, a combined error with joined messages and a lazily joined stack. Duplicate messages are skipped.\n\nRespects [`transient-error`](https://github.com/vweevers/transient-error) and `err.expected`: if all errors have `.transient === true` then the combined error will also be transient. Same for `.expected`, which is useful for the following pattern:\n\n```js\nif (err.expected) {\n  console.error(err.message)\n  process.exit(1)\n} else {\n  throw err\n}\n```\n\n## Alternatives\n\n### [`combine-errors`](https://github.com/MatthewMueller/combine-errors)\n\nSame message and stack behavior. Different in that it always returns an error regardless of input length.\n\n### [`aggregate-error`](https://github.com/sindresorhus/aggregate-error)\n\nSets message to a joined stack, which means you can't get a human-friendly message with e.g. `console.error(err.message)`. Removes \"mostly unhelpful\" internal Node.js entries from the stack.\n\n## Install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install maybe-combine-errors\n```\n\n## License\n\n[MIT](LICENSE.md) © 2020-present Vincent Weevers\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvweevers%2Fmaybe-combine-errors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvweevers%2Fmaybe-combine-errors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvweevers%2Fmaybe-combine-errors/lists"}