{"id":27293175,"url":"https://github.com/hellozee/errors","last_synced_at":"2025-04-11T22:42:51.973Z","repository":{"id":39711167,"uuid":"194553915","full_name":"hellozee/errors","owner":"hellozee","description":"An idiot's attempt to do a go like error handling in c++","archived":false,"fork":false,"pushed_at":"2022-05-27T08:23:23.000Z","size":44,"stargazers_count":12,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-21T11:28:41.371Z","etag":null,"topics":["cmake","cpp","error-handling","errors","exception-handling","exceptions","golang"],"latest_commit_sha":null,"homepage":"","language":"CMake","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hellozee.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}},"created_at":"2019-06-30T19:36:45.000Z","updated_at":"2024-04-21T11:28:41.371Z","dependencies_parsed_at":"2022-09-20T08:31:40.201Z","dependency_job_id":null,"html_url":"https://github.com/hellozee/errors","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellozee%2Ferrors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellozee%2Ferrors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellozee%2Ferrors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellozee%2Ferrors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hellozee","download_url":"https://codeload.github.com/hellozee/errors/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248492993,"owners_count":21113159,"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":["cmake","cpp","error-handling","errors","exception-handling","exceptions","golang"],"created_at":"2025-04-11T22:42:51.334Z","updated_at":"2025-04-11T22:42:51.963Z","avatar_url":"https://github.com/hellozee.png","language":"CMake","readme":"# If you are looking at this beware there are better alternatives like std::expected or if your C++ standard doesn't provide that there is [tl::expected](https://github.com/TartanLlama/expected)\n# errors\n\nAn idiot's attempt to do a `go` like error handling in `c++`\n\nReally simple library and obviously the code is self documenting, take a look at the examples if you want to use.\n\nUnfortunately there is no install rule but can be used as git submodule in a `cmake` project.\n\n### What inspired me?\n\nAlong with `c++`, I also use `go` at least for my personal projects. And I really like how `go` handles errors without the use of any exceptions or such. How does it do that? Simple by using multiple returns, one of which is the error and then we check if the error is nil or not. Like this,\n\n```go\nf, err := os.Open(\"filename.ext\")\nif err != nil {\n    //oops error\n}\n```\n\nI try to imitate the same thing in `c++`, for example I can write the above example using my library as\n\n```c++\n#include \u003cerrors.h\u003e\n..\n..\nerrors::container\u003ctype\u003e result = some_function(param);\nif(result.err() != errors::nil()){\n    //oops error\n}\n```\n\nThe library is a header only library. \n\nI try to avoid involving `std::exception` in the library, as well  as the resulting code, it is being used in, but I am not sure if I am able to get that, would be happy if someone could point me out an example where exceptions would involved and if possible can suggest a solution. :smile:\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhellozee%2Ferrors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhellozee%2Ferrors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhellozee%2Ferrors/lists"}