{"id":18536294,"url":"https://github.com/adishavit/mittens","last_synced_at":"2026-03-05T09:03:40.831Z","repository":{"id":72816502,"uuid":"58885224","full_name":"adishavit/mittens","owner":"adishavit","description":"Because somebody has to catch the hot potato!","archived":false,"fork":false,"pushed_at":"2016-05-22T06:41:09.000Z","size":46,"stargazers_count":18,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-06T11:05:44.367Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adishavit.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":"2016-05-15T21:26:19.000Z","updated_at":"2023-02-13T20:37:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"6f5a7cca-d596-461a-953b-932467c4cb69","html_url":"https://github.com/adishavit/mittens","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/adishavit/mittens","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adishavit%2Fmittens","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adishavit%2Fmittens/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adishavit%2Fmittens/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adishavit%2Fmittens/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adishavit","download_url":"https://codeload.github.com/adishavit/mittens/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adishavit%2Fmittens/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30117495,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T08:19:04.902Z","status":"ssl_error","status_checked_at":"2026-03-05T08:17:37.148Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-11-06T19:31:46.811Z","updated_at":"2026-03-05T09:03:40.778Z","avatar_url":"https://github.com/adishavit.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"![icon](mittens_icon.png) Mittens \n=======\n\nMittens is a cross-platform, C++ header-only library for centralized handling of exceptions, particularly along module boundaries. \n\nRobust software needs to be able to handle exceptions as gracefully as possible. This might include last-minute error logging, alternate notification mechanisms (e.g. via the JVM) etc. \n\nAn unexpected exit out of `main()` or an exception escaping from a DLL, COM or JNI function call can cause severe havoc. Module boundaries are stress-points where escaped exceptions should be firmly handled. Dynamically linked libraries (DLLs) export multiple C-like functions forming the dynamic module boundaries. Here, in particular, we would like a uniform and consistent way of handling exceptions. This often requires a lot of copy-paste code since try-catch statements do not naturally compose nor can they be easily encapsulated.\n\nMittens is a generic header-only library that allows `try-catch` statement composition, ordering and nesting with customizable actions per exception type. These composite exception handlers can be defined once and reused multiple times where needed. \n\n![icon](mittens_icon.png) Overview\n-----\n#### Features\n- Centralized, uniform, maintainable, consistent and composable exception handling;\n- Support both portable cross-platform and platform-specific code;\n- Write robust, well ordered, exception-type-specific custom code;\n- Particularly useful along module boundaries: e.g command-line applications and dynamically loaded libraries (DLLs, shared-object `.so`, Android JNI, etc.) \n\n#### TL;DR: Show Me the Code!\n```cpp\n#include \"common_handlers.hpp\"\n\nauto handleIt = mittens::all_catcher               (-1, []()       { std::cerr \u003c\u003c \"Caught exception of unknown type!\"   \u003c\u003c std::endl; }, \n                   mittens::std_exception_handler  (-2, [](auto\u0026 e){ std::cerr \u003c\u003c \"Caught std::exception: \" \u003c\u003c e.what() \u003c\u003c std::endl; },\n                      mittens::generic_handler\u003cint\u003e(-3, [](auto\u0026 e){ std::cerr \u003c\u003c \"Caught thrown `int` = \"  \u003c\u003c e        \u003c\u003c std::endl; })));\n\nint main() try\n{\n   throw std::runtime_error(\"Goodbye World, Hello Mittens!\");\n   return EXIT_SUCCESS;\n}\ncatch (...) \n{  return handleIt(); }\n```\nApplication prints: `Caught std::exception: Goodbye World, Hello Mittens!` and the app return value will be `-2`.\n\n**See the [Tutorial](https://github.com/adishavit/mittens/wiki/The-Mittens-Tutorial) for more.**\n\n#### Integration\n- Single header file `generic_exception_handler.hpp` + optional helper header (`common_handlers.hpp`).\n- Cross platform: Windows, Linux OSX;\n- No external dependencies (but unit tests use Boost.Test);\n- BSD License \n\n#### Epilogue\n- Mittens grew out of the need to robustly and consistently handle exceptions across module boundaries in Windows DLLs and Android JNIs. \n- The first version was written in 2013. This repo is a complete rewrite to allow for much more genericity.\n- Although the design is very different, Mittens was originally inspired by Matthew Wilson's Quality Matters articles ([QM#6](http://accu.org/index.php/journals/1706), [QM#7](http://accu.org/index.php/articles/1868)).  \n- Check out the `examples` folder for more examples of how Mittens can help you and more advanced usage.\n- Comments, discussions, questions, ideas and PRs are most welcome!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadishavit%2Fmittens","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadishavit%2Fmittens","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadishavit%2Fmittens/lists"}