{"id":17573896,"url":"https://github.com/zgiber/batcherror","last_synced_at":"2026-02-07T06:02:07.123Z","repository":{"id":257809098,"uuid":"867045078","full_name":"zgiber/batcherror","owner":"zgiber","description":"Handle individual errors in batch operations where signature doesn't accommodate linking errors to results.","archived":false,"fork":false,"pushed_at":"2024-10-10T15:48:38.000Z","size":11,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-30T00:15:53.434Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/zgiber.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}},"created_at":"2024-10-03T10:59:06.000Z","updated_at":"2024-10-11T04:37:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"6a9defe9-1fd5-477e-9ce1-1966bf29bd99","html_url":"https://github.com/zgiber/batcherror","commit_stats":null,"previous_names":["zgiber/batcherror"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zgiber/batcherror","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zgiber%2Fbatcherror","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zgiber%2Fbatcherror/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zgiber%2Fbatcherror/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zgiber%2Fbatcherror/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zgiber","download_url":"https://codeload.github.com/zgiber/batcherror/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zgiber%2Fbatcherror/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29187938,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T05:07:31.176Z","status":"ssl_error","status_checked_at":"2026-02-07T05:06:15.227Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":[],"created_at":"2024-10-21T21:43:00.686Z","updated_at":"2026-02-07T06:02:07.107Z","avatar_url":"https://github.com/zgiber.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# batcherror\n\nKeep track of individual errors within a batched process.\n\n## Why?\n\nSometimes a batch operation is required to implement an existing interface that has a singular error return type.\nThis package can help with conveying and consulting individual errors in the returned error. \nIt works well with the errors package by the standard library.\n\n## Why not?\n\nOften it is simpler to return a custom type from a batch process, something like:\n\n```go\n\ntype batchResult struct {\n\toutputData any\n\terr error\n}\n\nfunc myBatchFunc(inputData []any) []batchResult {\n\t// ...\n}\n```\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\n\t\"github.com/zgiber/batcherror\"\n)\n\nfunc main() {\n\titems := []any{1, 2, 3, \"foo\", 4, \"bar\", 5, 6}\n\tif err := processItems(items); err != nil {\n\t\tfmt.Println(err)\n\t\t// not an integer at [3]\n\t\t// not an integer at [5]\n\n\t\tfmt.Println(batcherror.At(err, 1) == nil)\n\t\t// true\n\n\t\tfmt.Println(batcherror.At(err, 3))\n\t\t// not an integer at [3]\n\n\t\tfor k, v := range batcherror.Map(err) {\n\t\t\tfmt.Println(k, v)\n\t\t\t// 3 not an integer at [3]\n\t\t\t// 5 not an integer at [5]\n\t\t}\n\t}\n}\n\nfunc processItems(items []any) error {\n\tvar batchErr error\n\tfor idx, item := range items {\n\t\tif _, ok := item.(int); !ok {\n\t\t\tbatchErr = errors.Join(batchErr, batcherror.New(fmt.Errorf(\"not an integer\"), idx))\n\t\t}\n\t}\n\treturn batchErr\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzgiber%2Fbatcherror","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzgiber%2Fbatcherror","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzgiber%2Fbatcherror/lists"}