{"id":15285728,"url":"https://github.com/denchenn/blunder","last_synced_at":"2025-05-07T04:24:52.148Z","repository":{"id":167193117,"uuid":"642536774","full_name":"DenChenn/blunder","owner":"DenChenn","description":"A modern golang error handling package powered by GPT-3.","archived":false,"fork":false,"pushed_at":"2023-09-14T11:35:21.000Z","size":45,"stargazers_count":15,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-19T18:30:37.802Z","etag":null,"topics":["codegen","error-handling","gin","golang","gpt-3","grpc","template"],"latest_commit_sha":null,"homepage":"","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/DenChenn.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}},"created_at":"2023-05-18T19:48:40.000Z","updated_at":"2024-03-30T08:55:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"2f3fdc12-9762-4075-aee7-af78c4e108ae","html_url":"https://github.com/DenChenn/blunder","commit_stats":{"total_commits":34,"total_committers":2,"mean_commits":17.0,"dds":0.02941176470588236,"last_synced_commit":"57bc4d3fb261029022ec3e3c0e3f4f058c39c11c"},"previous_names":["denchenn/blunder"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DenChenn%2Fblunder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DenChenn%2Fblunder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DenChenn%2Fblunder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DenChenn%2Fblunder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DenChenn","download_url":"https://codeload.github.com/DenChenn/blunder/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252811579,"owners_count":21807969,"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":["codegen","error-handling","gin","golang","gpt-3","grpc","template"],"created_at":"2024-09-30T15:07:22.318Z","updated_at":"2025-05-07T04:24:52.126Z","avatar_url":"https://github.com/DenChenn.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Blunder\n![GitHub](https://img.shields.io/github/license/DenChenn/blunder)\n![Go Report Card](https://goreportcard.com/badge/github.com/DenChenn/blunder)\n\n## What is Blunder?\nBlunder is a simple, gpt-based and easy-to-use error handling package for golang. \nIt generate typed errors and manage them in centralized way, which reduce the dependency between packages and make error handling more convenient.\n\n## Getting Started\n1. Install package\n   ```bash\n    go get github.com/DenChenn/blunder\n   ```\n2. Import into your project\n   ```bash\n   printf '// +build tools\\npackage tools\\nimport (_ \"github.com/DenChenn/blunder\")' | gofmt \u003e tools.go\n\n   go mod tidy\n   ```\n3. Initialize Blunder\n   ```bash\n    go run github.com/DenChenn/blunder init \u003cyour_dir_path\u003e\n   ```\n3. Define your error in `blunder.yaml` according to example ❤️\n4. Generate all errors\n   ```bash\n    go run github.com/DenChenn/blunder gen\n   ```\n   or generate with gpt-based auto-completion\n   ```bash\n    export OPENAI_API_TOKEN=\u003cyour_openai_api_token\u003e\n    go run github.com/DenChenn/blunder gen --complete=true \n   ```\n\n## Usage\nSuppose your errors in `blunder.yaml` are defined like this:\n```yaml\ndetails:\n- package: alayer\n  errors:\n    - code: Err1\n      #...\n    - code: Err2\n      #...\n    - code: Err3\n      #...\n- package: blayer\n  errors:\n    - code: Err1\n      #...\n    - code: Err2\n      #...\n    - code: Err3\n      #...\n```\n\nYour error will be generated in given path like this:\n```\n\u003cyour_dir_path\u003e/errors/\ngenerated/\n  alayer/ \n    errors.go\n  blayer/\n    errors.go\nblunder.yaml\n```\n\nWhich can be import into your code like this:\n```go\nif err != nil {\n  if errors.Is(err, \u0026alayer.Err1) {\n    //...\n  }\n}\n```\n\nOr you can wrap your error like this:\n```go\nif errors.Is(err, \u0026pgx.ErrNoRows) {\n  return \u0026alayer.Err1.Wrap(err) \n}\n```\n\n## Type assertion\nAll generated errors implement `blunder.OrdinaryError` interface, which contains static methods.\n\n```go\nordinaryError, ok := err.(blunder.OrdinaryError)\nif ok {\n\tfmt.Println(ordinaryError.GetMessage())\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenchenn%2Fblunder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdenchenn%2Fblunder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenchenn%2Fblunder/lists"}