{"id":19437012,"url":"https://github.com/netologist/yeh","last_synced_at":"2025-02-25T07:13:49.456Z","repository":{"id":137875474,"uuid":"494750709","full_name":"netologist/yeh","owner":"netologist","description":"Yet another Error Handler for Golang","archived":false,"fork":false,"pushed_at":"2022-05-28T06:19:32.000Z","size":22,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-07T21:15:50.683Z","etag":null,"topics":["error-handling","go-library","golang"],"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/netologist.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}},"created_at":"2022-05-21T10:26:22.000Z","updated_at":"2023-11-07T12:59:50.000Z","dependencies_parsed_at":"2024-01-24T06:03:38.079Z","dependency_job_id":null,"html_url":"https://github.com/netologist/yeh","commit_stats":null,"previous_names":["hasanozgan/yeh"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netologist%2Fyeh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netologist%2Fyeh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netologist%2Fyeh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netologist%2Fyeh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netologist","download_url":"https://codeload.github.com/netologist/yeh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240619450,"owners_count":19830206,"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":["error-handling","go-library","golang"],"created_at":"2024-11-10T15:13:17.556Z","updated_at":"2025-02-25T07:13:49.401Z","avatar_url":"https://github.com/netologist.png","language":"Go","readme":"# yeh\n**Y**et another **E**rror **H**andler for Golang. \n\n*This Project An **Experimental** Idea For Error Handler Implementation With Go Generics*\n\n## Examples\n\n### Must\n\nAlso Must has support *Must0, Must2, Must3, Must4* and *Must5* methods. For multiple return types.\n\n```go\n\ngot := func() (err error) {\n    defer yeh.Recover(\u0026err)\n\n    value := yeh.Must(os.Open(\"file.not.exists.txt\"))\n\n    fmt.Printf(\"Output: %d\\n\", value)\n\n    return nil\n}()\n\nif got == nil {\n    t.Errorf(\"Failed\")\n}\n\nif got != fs.ErrExist {\n    t.Errorf(\"Failed\")\n}\n\n```\n\n### MustWith\n\nAlso Must has support *MustWith0, MustWith2, MustWith3, MustWith4* and *MustWith5* methods. For multiple return types.\n\n#### Replace\n```go\n\ngot := func() (err error) {\n    defer yeh.Recover(\u0026err)\n\n    outputValue := yeh.MustWith(os.Open(\"file.not.exists.txt\")).Replace(ErrCustomExists)\n\n    fmt.Printf(\"Output: %d\\n\", outputValue)\n\n    return nil\n}()\n\nif got == nil {\n    t.Errorf(\"Failed, unexpected error\")\n}\n\nif got == fs.ErrExist {\n    t.Errorf(\"Failed, unexpected error\")\n}\n\nif got != ErrCustomExists {\n    t.Errorf(\"Failed, unexpected error\")\n}\n\n```\n\n#### Wrap\n```go\n\ngot := func() (err error) {\n\tdefer yeh.Recover(\u0026err)\n\n\toutputValue := yeh.MustWith(os.Open(\"file.not.exists.txt\")).Wrap(ErrCustomExists)\n\n\tfmt.Printf(\"Output: %d\\n\", outputValue)\n\n\treturn nil\n}()\n\nif got == nil {\n\tt.Errorf(\"Failed, unexpected error\")\n}\n\nif !strings.HasPrefix(got.Error(), fs.ErrExist.Error()) {\n\tt.Errorf(\"Failed, unexpected error\")\n}\n\nif !errors.Is(got, ErrCustomExists) {\n\tt.Errorf(\"Failed, unexpected error\")\n}\n\n```\n\n#### Callback\n```go\n\ngot := func() (err error) {\n\tdefer yeh.Recover(\u0026err)\n\n\toutputValue := yeh.MustWith(os.Open(\"file.not.exists.txt\")).Callback(func(err error) error {\n\t\tif errors.Is(err, fs.) {\n\t\t\treturn ErrCustomExists\n\t\t}\n\t\treturn err\n\t})\n\n\tfmt.Printf(\"Output: %d\\n\", outputValue)\n\n\treturn nil\n}()\n\nif got == nil {\n\tt.Errorf(\"Failed, unexpected error\")\n}\n\nif got == fs.ErrExist {\n\tt.Errorf(\"Failed, unexpected error\")\n}\n\nif got != ErrCustomExists {\n\tt.Errorf(\"Failed, unexpected error\")\n}\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetologist%2Fyeh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetologist%2Fyeh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetologist%2Fyeh/lists"}