{"id":51173578,"url":"https://github.com/btravstack/unthrown","last_synced_at":"2026-06-30T03:00:40.049Z","repository":{"id":367417850,"uuid":"1280121486","full_name":"btravstack/unthrown","owner":"btravstack","description":"Explicit errors as values for TypeScript — with a separate defect channel for the unexpected and qualification enforced at every boundary.","archived":false,"fork":false,"pushed_at":"2026-06-26T16:27:00.000Z","size":329,"stargazers_count":4,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-06-27T02:18:32.947Z","etag":null,"topics":["async","defect","either","error-handling","errors-as-values","esm","functional-programming","monad","railway-oriented-programming","result","result-type","tagged-error","type-safe","typescript","zero-dependencies"],"latest_commit_sha":null,"homepage":"https://btravstack.github.io/unthrown/","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/btravstack.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-25T09:36:31.000Z","updated_at":"2026-06-26T17:13:02.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/btravstack/unthrown","commit_stats":null,"previous_names":["btravers/unthrown"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/btravstack/unthrown","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/btravstack%2Funthrown","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/btravstack%2Funthrown/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/btravstack%2Funthrown/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/btravstack%2Funthrown/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/btravstack","download_url":"https://codeload.github.com/btravstack/unthrown/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/btravstack%2Funthrown/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34950330,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-30T02:00:05.919Z","response_time":92,"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":["async","defect","either","error-handling","errors-as-values","esm","functional-programming","monad","railway-oriented-programming","result","result-type","tagged-error","type-safe","typescript","zero-dependencies"],"created_at":"2026-06-27T02:04:59.474Z","updated_at":"2026-06-30T03:00:40.042Z","avatar_url":"https://github.com/btravstack.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/public/logo.svg\" alt=\"unthrown\" width=\"128\" height=\"128\" /\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eunthrown\u003c/h1\u003e\n\n\u003e Explicit errors as values for TypeScript — with a separate defect channel for\n\u003e the unexpected, and qualification enforced at every boundary.\n\n[![CI](https://github.com/btravstack/unthrown/actions/workflows/ci.yml/badge.svg)](https://github.com/btravstack/unthrown/actions/workflows/ci.yml)\n[![npm](https://img.shields.io/npm/v/unthrown.svg)](https://www.npmjs.com/package/unthrown)\n[![license](https://img.shields.io/npm/l/unthrown.svg)](./LICENSE)\n\nOrdinary errors are _unthrown_ — returned as values, not flung up the stack.\nOnly a true defect ever throws, and only at `unwrap`.\n\n📖 **[Documentation](https://btravstack.github.io/unthrown/)** ·\n[Why unthrown?](https://btravstack.github.io/unthrown/guide/why-unthrown) ·\n[Getting Started](https://btravstack.github.io/unthrown/guide/getting-started)\n\n## Why?\n\nMost errors-as-values libraries model _anticipated_ failures in `Result\u003cT, E\u003e`\nbut have no channel for the _unexpected_ — a thrown `TypeError`, an un-triaged\npromise rejection, a bug in a callback. Fold both into the same `E` and a bug\nstarts to look like a domain error.\n\n`unthrown` keeps a third runtime state — a **`Defect`** — that is **invisible to\nthe type**. `E` lists only your anticipated errors; anything unexpected becomes a\ndefect that short-circuits to the edge, where you log it and return a 500.\n\n- **Errors as values.** `map` / `flatMap` / `match` over a `Result\u003cT, E\u003e`.\n- **A separate defect channel.** Unmodeled failures can't masquerade as domain\n  errors, and can only be observed by `match` or `recoverDefect`.\n- **Qualification at every boundary.** `fromPromise` / `fromThrowable` force you\n  to triage each failure into a modeled error or a defect — no path yields\n  `unknown` in `E`.\n- **Small and done-able.** Zero runtime dependencies, ESM-first, dual CJS/ESM,\n  fully typed.\n\nSee [Why unthrown?](https://btravstack.github.io/unthrown/guide/why-unthrown) for\nthe comparison with `neverthrow`, `boxed`, and `effect`.\n\n## Install\n\n```sh\npnpm add unthrown\n```\n\n## Example\n\n```ts\nimport { fromPromise, Defect, TaggedError } from \"unthrown\";\n\nclass NotFound extends TaggedError(\"NotFound\") {}\n\n// Cross an async boundary — every rejection MUST be triaged into E or a defect.\nconst user = fromPromise(fetchUser(id), (cause) =\u003e\n  cause instanceof NotFoundError ? new NotFound() : Defect(cause),\n);\n\n// Handle every channel once, at the edge — no surrounding try/catch.\nconst status = await user.match({\n  ok: () =\u003e 200,\n  err: () =\u003e 404, // your modeled NotFound\n  defect: (cause) =\u003e {\n    logger.error(cause); // everything unexpected\n    return 500;\n  },\n});\n```\n\nA `throw` inside any combinator (`.map`, `.flatMap`, …) is caught and becomes a\ndefect, so the edge of your program needs a single `match` and no `try`/`catch`.\n\n## Packages\n\n| Package                                         | Description                                                                                    |\n| ----------------------------------------------- | ---------------------------------------------------------------------------------------------- |\n| [`unthrown`](./packages/core)                   | The core `Result` / `AsyncResult`, interop, `TaggedError`, `matchTags`. Zero runtime deps.     |\n| [`@unthrown/vitest`](./packages/vitest)         | Vitest matchers: `toBeOk`, `toBeOkWith`, `toBeErr`, `toBeErrTagged`, `toBeDefect`.             |\n| [`@unthrown/pattern`](./packages/pattern)       | Thin `ts-pattern` sugar for the natively-matchable `Result`: `P.Ok`/`P.Err`/`P.Defect`, `tag`. |\n| [`@unthrown/effect`](./packages/effect)         | Effect interop: `Result ↔ Exit` (bijection), `Either`, `Effect`.                               |\n| [`@unthrown/neverthrow`](./packages/neverthrow) | neverthrow interop: `Result ↔ Result`, `AsyncResult ↔ ResultAsync`.                            |\n| [`@unthrown/boxed`](./packages/boxed)           | Boxed interop: `Result ↔ Result`, `AsyncResult ↔ Future\u003cResult\u003e`.                              |\n\n## Contributing\n\nThis is a pnpm + turbo monorepo. Common tasks:\n\n```sh\npnpm install\npnpm build        # build all packages (tsdown, dual CJS/ESM)\npnpm test         # run the Vitest suites\npnpm typecheck    # tsc --noEmit across packages\npnpm lint         # oxlint\npnpm format       # oxfmt\n```\n\n## License\n\n[MIT](./LICENSE) © Benoit TRAVERS\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbtravstack%2Funthrown","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbtravstack%2Funthrown","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbtravstack%2Funthrown/lists"}