{"id":30576634,"url":"https://github.com/neko-box-coder/dsresult","last_synced_at":"2025-08-29T01:08:45.349Z","repository":{"id":306826981,"uuid":"1022272683","full_name":"Neko-Box-Coder/DSResult","owner":"Neko-Box-Coder","description":"A simple struct for allowing golang or rust like error handling","archived":false,"fork":false,"pushed_at":"2025-07-27T20:13:34.000Z","size":9,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-27T22:11:48.166Z","etag":null,"topics":["cpp","cpp11","error","error-handling","expected","handling","trace"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Neko-Box-Coder.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":"2025-07-18T18:49:51.000Z","updated_at":"2025-07-27T20:20:35.000Z","dependencies_parsed_at":"2025-07-27T22:21:56.149Z","dependency_job_id":null,"html_url":"https://github.com/Neko-Box-Coder/DSResult","commit_stats":null,"previous_names":["neko-box-coder/dsresult"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Neko-Box-Coder/DSResult","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neko-Box-Coder%2FDSResult","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neko-Box-Coder%2FDSResult/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neko-Box-Coder%2FDSResult/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neko-Box-Coder%2FDSResult/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Neko-Box-Coder","download_url":"https://codeload.github.com/Neko-Box-Coder/DSResult/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neko-Box-Coder%2FDSResult/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272596696,"owners_count":24962123,"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","status":"online","status_checked_at":"2025-08-28T02:00:10.768Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["cpp","cpp11","error","error-handling","expected","handling","trace"],"created_at":"2025-08-29T01:08:43.903Z","updated_at":"2025-08-29T01:08:45.341Z","avatar_url":"https://github.com/Neko-Box-Coder.png","language":"C++","readme":"# Dead Simple Result With Error Tracing\n\nA single header only simple C++11 struct for allowing golang/rust like error handling and tracing\nwith expected like container\n\nSupports [tl::expected](https://github.com/TartanLlama/expected), \n[expected lite](https://github.com/martinmoene/expected-lite.git),\n[std expected](https://cppreference.com/w/cpp/header/expected.html) or custom expected like container.\n\nJust add `Include` to your project include path and do `#include \"DSResult/DSResult.hpp\"`.\n\nBy default it uses `tl::expected`, if nothing is instructed. Define the following macro to choose \na different backend\n\n```cpp\n#define DS_USE_TL_EXPECTED 1\n#define DS_USE_EXPECTED_LITE 1\n#define DS_USE_STD_EXPECTED 1\n#define DS_USE_CUSTOM_EXPECTED 1\n```\n\nIf you are using a custom expected like container, you need to define the macros `DS_EXPECTED_TYPE` \nand `DS_UNEXPECTED_TYPE`. For example, \n\n```cpp\n#define DS_EXPECTED_TYPE MyNamespace::MyExpected        //MyNamespace::MyExpected\u003cT, E\u003e\n#define DS_UNEXPECTED_TYPE MyNamespace::MyUnexpected    //MyNamespace::MyUnexpected\u003cE\u003e\n```\n\n---\n\n## Usage\n\n### Type Definitions\n```cpp\ntemplate\u003ctypename T\u003e\nusing Result = DS_EXPECTED_TYPE\u003cT, DS::ErrorTrace\u003e;\nusing Error = DS_UNEXPECTED_TYPE\u003cDS::ErrorTrace\u003e;\n```\n\nSee the respective expected and unexpected type on how to use them, but mainly the following\n- `bool DS::Result\u003cT\u003e::has_value()`\n- `T\u0026 DS::Result\u003cT\u003e::value()`\n- `DS::Error DS::Result\u003cT\u003e::error()`\n\n### Function Declaration that uses DS::Result\n```cpp\nDS::Result\u003cint\u003e MyFunction(...);\n```\n\n### Returning an error message\n```cpp\nint myValue;\nreturn DS::Error(DS_ERROR_MSG(\"Something wrong: \" + DS_STR(myValue)));\n```\n\n### Return error if assertion fails\n```cpp\nstd::vector\u003cint\u003e myData;\nDS_ASSERT_RETURN(!myData.empty());  //Returns DS::Error if `myData.empty()` is true\n```\n\n### Check result, append to trace and return if there's an error\n```cpp\nDS::Result\u003cvoid\u003e MyVoidFunction()\n{\n    DS::Result\u003cint\u003e functionResult = MyFunction();\n    DS_CHECKED_RETURN(functionResult);\n    int myInt = functioonResult.value();\n    return {};\n}\n```\n\n### Get the error trace if a function failed\n```cpp\n#include \u003ciostream\u003e\nint main()\n{\n    DS::Result\u003cvoid\u003e result = MyFunction();\n    if(!result.has_value())\n    {\n        DS::ErrorTrace errorTrace = DS_APPEND_TRACE(result.error());\n        //Error:\n        //  ...\n        //\n        //Stack trace\n        //  at ...\n        //  at ...\n        //  ...\n        std::cout \u003c\u003c errorTrace.ToString() \u003c\u003c std::endl;\n        return 1;\n    }\n    return 0;\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneko-box-coder%2Fdsresult","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneko-box-coder%2Fdsresult","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneko-box-coder%2Fdsresult/lists"}