{"id":22496983,"url":"https://github.com/morebec/go-errors","last_synced_at":"2025-03-27T21:25:34.706Z","repository":{"id":65211560,"uuid":"587142262","full_name":"Morebec/go-errors","owner":"Morebec","description":"Go package built on top of go's standard errors","archived":false,"fork":false,"pushed_at":"2023-03-30T09:53:51.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T23:45:10.295Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Morebec.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-01-10T03:48:36.000Z","updated_at":"2023-01-11T14:17:01.000Z","dependencies_parsed_at":"2024-06-20T18:53:04.337Z","dependency_job_id":null,"html_url":"https://github.com/Morebec/go-errors","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morebec%2Fgo-errors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morebec%2Fgo-errors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morebec%2Fgo-errors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morebec%2Fgo-errors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Morebec","download_url":"https://codeload.github.com/Morebec/go-errors/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245925708,"owners_count":20694947,"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","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-12-06T20:15:07.764Z","updated_at":"2025-03-27T21:25:34.682Z","avatar_url":"https://github.com/Morebec.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-errors\n[![Go](https://github.com/Morebec/go-errors/actions/workflows/go.yml/badge.svg?branch=main)](https://github.com/Morebec/go-errors/actions/workflows/go.yml)\n\nThis package is a thin wrapper around the Go standard library's errors \npackage that provides additional functions for defining and manipulating errors. It is designed to be compatible with \nthe standard library's errors package, but also provides additional features such as the ability to define custom error \ncodes (for translation or representation in UIs) and the ability to wrap multiple errors in a single error value.\n\n## Features\n- Define custom error codes with the `Error` type.\n- Wrap multiple errors in a single error value with the `Group` type.\n- Retrieve the cause of an error with the `Unwrap` method.\n\n## Getting Started\nTo get started with the `go-errors` package, you can install it with the following command:\n\n```bash\ngo get github.com/morebec/go-errors\n```\n\n## Examples \nHere are a few examples, for more examples please consult the `errors_test.go` file.\n### Adding context to an error\n```go\n_, err := os.ReadFile(f)\nif err != nil {\n\treturn errors.WrapWithMessage(err, \"reading_failure\", \"there was an error reading the file\")\n}\n```\n\n\n\n### Handling an error with a specific error code\n```go\nimport \"github.com/morebec/go-errors/errors\"\n\nfunc doSomething() error {\n\t// Return a new error with the \"invalid_input\" code.\n\treturn errors.New(\"invalid_input\")\n\t\n\t// alternatively if you also want to provide a message\n\treturn errors.NewWithMessage(\"invalid_input\", \"The input provided was invalid.\")\n}\n\nfunc main() {\n\terr := doSomething()\n\tif err != nil {\n\t\tif errors.HasCode(err, \"invalid_input\") {\n\t\t    // Do something ...\n        }\n\t}\n}\n```\n\n\n### Contributions\nWe welcome contributions to the `go-errors` package! If you have an idea for a new feature or have found a bug, \nplease open an issue to discuss it. If you'd like to contribute code, please open a pull request with your changes.\n\nLicense\nThe `go-errors` package is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorebec%2Fgo-errors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorebec%2Fgo-errors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorebec%2Fgo-errors/lists"}