{"id":51063608,"url":"https://github.com/deblasis/zioerrors","last_synced_at":"2026-06-23T04:30:33.299Z","repository":{"id":354880501,"uuid":"1224770829","full_name":"deblasis/zioerrors","owner":"deblasis","description":"Error context breadcrumbs for Zig. Pin failures with structured payload, recover the chain at the boundary.","archived":false,"fork":false,"pushed_at":"2026-04-30T16:31:27.000Z","size":47,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-30T18:15:35.534Z","etag":null,"topics":["anyhow","breadcrumbs","error-context","error-handling","zig"],"latest_commit_sha":null,"homepage":null,"language":"Zig","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/deblasis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","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":"AGENTS.md","dco":null,"cla":null},"funding":{"github":["deblasis"],"ko_fi":"deblasis","custom":"deblasis.eth"}},"created_at":"2026-04-29T15:58:20.000Z","updated_at":"2026-04-30T16:31:31.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/deblasis/zioerrors","commit_stats":null,"previous_names":["deblasis/zioerrors"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/deblasis/zioerrors","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deblasis%2Fzioerrors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deblasis%2Fzioerrors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deblasis%2Fzioerrors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deblasis%2Fzioerrors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deblasis","download_url":"https://codeload.github.com/deblasis/zioerrors/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deblasis%2Fzioerrors/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34675970,"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-23T02:00:07.161Z","response_time":65,"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":["anyhow","breadcrumbs","error-context","error-handling","zig"],"created_at":"2026-06-23T04:30:32.441Z","updated_at":"2026-06-23T04:30:33.294Z","avatar_url":"https://github.com/deblasis.png","language":"Zig","funding_links":["https://github.com/sponsors/deblasis","https://ko-fi.com/deblasis","deblasis.eth"],"categories":[],"sub_categories":[],"readme":"# zioerrors\n\nError context breadcrumbs for Zig's bare error union. Pin failures\nwith structured payload, recover the chain at the boundary. Inspired\nby Rust's `anyhow` / `eyre` and Go's wrapped errors.\n\n## Before / after\n\nWithout zioerrors (a typical \"what failed and why\" pattern):\n\n```zig\nconst file = std.fs.cwd().openFile(path, .{}) catch |err| {\n    std.log.err(\n        \"loading config failed: {s} (path={s}, user_id={d})\",\n        .{ @errorName(err), path, user_id },\n    );\n    return err;\n};\n```\n\nWith zioerrors (4 lines, structured, chains automatically):\n\n```zig\nconst file = std.fs.cwd().openFile(path, .{}) catch |err| {\n    return zioerrors.fail(err, @src()).ctx(\"loading config\")\n        .attr(\"path\", path).attr(\"user_id\", user_id).err();\n};\n```\n\nAt the boundary:\n\n```zig\nwork() catch |err| {\n    std.log.err(\"{f}\", .{zioerrors.report(err)});\n    return err;\n};\n```\n\nOutput:\n\n```\nerror.FileNotFound: loading config (path=/etc/app.toml, user_id=42)\n  at src/config.zig:42\n```\n\nIf a wrapping function adds more context, the chain is preserved:\n\n```\nerror.FileNotFound: starting up (phase=config)\n  at src/app.zig:23\ncaused by error.FileNotFound: loading config (path=/etc/app.toml)\n  at src/config.zig:42\n```\n\n## Install\n\n```bash\nzig fetch --save git+https://github.com/deblasis/zioerrors\n```\n\nThen in your `build.zig`:\n\n```zig\nconst zio_dep = b.dependency(\"zioerrors\", .{\n    .target = target,\n    .optimize = optimize,\n});\nexe.root_module.addImport(\"zioerrors\", zio_dep.module(\"zioerrors\"));\n```\n\nRequires Zig 0.16.\n\n## Quickstart\n\n```zig\nconst std = @import(\"std\");\nconst zioerrors = @import(\"zioerrors\");\n\npub fn main() !void {\n    var gpa: std.heap.DebugAllocator(.{}) = .{};\n    defer _ = gpa.deinit();\n\n    var ctx = zioerrors.Context.init(gpa.allocator());\n    defer ctx.deinit();\n    zioerrors.install(\u0026ctx);\n    defer zioerrors.uninstall();\n\n    work() catch |err| {\n        var buf: [1024]u8 = undefined;\n        var w: std.Io.Writer = .fixed(\u0026buf);\n        zioerrors.report(err).format(\u0026w) catch {};\n        std.debug.print(\"{s}\\n\", .{buf[0..w.end]});\n        return err;\n    };\n}\n\nfn work() !void {\n    return zioerrors.failf(\n        error.NotImplemented,\n        @src(),\n        \"demo failure (n={d})\",\n        .{42},\n    );\n}\n```\n\n## API\n\n- `zioerrors.Context.init(allocator)`: create a per-thread context.\n- `zioerrors.install(\u0026ctx)` / `uninstall()`: bind / unbind for this thread.\n- `zioerrors.fail(err, @src())`: push a frame, returns a Builder.\n  - `.ctx(msg)` / `.ctxf(fmt, args)`: set the frame message.\n  - `.attr(key, value)`: typed attribute (string, signed int, unsigned int, float, bool).\n  - `.err()`: terminal, returns the original error.\n- `zioerrors.failf(err, @src(), fmt, args)`: one-shot wrap with a formatted line.\n- `zioerrors.report(err)`: snapshot the chain for printing as `{f}`.\n- `zioerrors.clear()`: drop frames, reset arena (call between independent operations).\n\n## Examples\n\nSee `examples/cli/main.zig`. Run with `zig build run-example`.\n\n## FAQ\n\n**Why thread-local?** It keeps function signatures bare-`!T`: no\nextra parameters, no `Result(T)` wrapping. The cost is one\n`Context.init` / `Context.deinit` per thread plus calling `install`\nonce. Cross-thread error propagation is out of scope (use your own\nchannel and re-attach context on the receiving thread).\n\n**Why must I pass `@src()`?** Zig has no parameter defaults and\n`inline fn` does not capture the caller's `@src()`. Passing it\nexplicitly costs one token per call but means the recorded frame\npoints at your code, not at the library wrapper.\n\n**What if I forget to `clear()`?** Stale frames from a previous\nfailure will appear in a later report. The fix is to `clear()` at\neach boundary.\n\n**Allocation behavior?** Zero allocation on the happy path.\nAllocations happen only inside `fail`, `ctx`, `ctxf`, and `attr`\npaths, and go to the per-thread arena, which is reclaimed in O(1) by\n`clear()`.\n\n**What about OOM during context capture?** If the arena fails to\nallocate while recording context, the frame or attribute is silently\ndropped. The original error still propagates. Trade-off: the library\nnever widens your error set with its own `error.OutOfMemory`.\n\n## Design\n\nSee `docs/superpowers/SEED.md` for the original brief and\n`docs/superpowers/specs/2026-04-29-zioerrors-design.md` for the v0.1\ndesign notes.\n\n## Compatibility\n\n- **Zig**: 0.16.0 (tracked in CI; earlier versions are not supported).\n- **Platforms**: tested on Linux (x86_64), macOS (x86_64, aarch64), Windows (x86_64).\n- **Breaking changes**: pinned to the Zig 0.16 stable release cycle. A major-version bump in Zig may require a major-version bump here.\n\n\n## License\n\nMIT. Copyright (c) 2026 Alessandro De Blasis.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeblasis%2Fzioerrors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeblasis%2Fzioerrors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeblasis%2Fzioerrors/lists"}