{"action":"opened","issue":{"url":"https://api.github.com/repos/tomas-zemres/syntax-feature-try/issues/5","labels_url":"https://api.github.com/repos/tomas-zemres/syntax-feature-try/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/tomas-zemres/syntax-feature-try/issues/5/comments","events_url":"https://api.github.com/repos/tomas-zemres/syntax-feature-try/issues/5/events","html_url":"https://github.com/tomas-zemres/syntax-feature-try/issues/5","id":100432572,"number":5,"title":"Support injecting a custom exception handler","user":{"login":"danschmidt5189","id":2547585,"avatar_url":"https://avatars.githubusercontent.com/u/2547585?v=3","gravatar_id":"","url":"https://api.github.com/users/danschmidt5189","html_url":"https://github.com/danschmidt5189","followers_url":"https://api.github.com/users/danschmidt5189/followers","following_url":"https://api.github.com/users/danschmidt5189/following{/other_user}","gists_url":"https://api.github.com/users/danschmidt5189/gists{/gist_id}","starred_url":"https://api.github.com/users/danschmidt5189/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danschmidt5189/subscriptions","organizations_url":"https://api.github.com/users/danschmidt5189/orgs","repos_url":"https://api.github.com/users/danschmidt5189/repos","events_url":"https://api.github.com/users/danschmidt5189/events{/privacy}","received_events_url":"https://api.github.com/users/danschmidt5189/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-08-11T23:17:48Z","updated_at":"2015-08-11T23:17:48Z","closed_at":null,"body":"Support for new type checkers has come up twice now - once for Moose::Util::TypeConstraints (#4) and once for [Type::Tiny](https://rt.cpan.org/Public/Bug/Display.html?id=99388).\r\n\r\nI second @tobyink 's suggestion (on CPAN, see link) to add Type::Tiny support, and I agree that a general solution would be better than adding another one-off fix.\r\n\r\nI think the syntax suggested in the CPAN issue is great - control on a package-level basis is really nice. But I think that by far the more common use-case will be to set a global (application / process-wide) handler.\r\n\r\nSome ideas:\r\n\r\n```perl\r\n# Set a custom catcher in the current package:\r\nuse syntax try => { exception_handler => \\&my_handler };\r\n\r\n# Set a custom catcher globally for your app:\r\n$Syntax::Feature::Try::exception_handler = \\&my_handler;\r\n\r\n# Catcher signature:\r\nsub my_handler {\r\n    my ($exception, $catch_name, $default_handler) = @_;\r\n    # Return truthy / falsey to indicate that the exception\r\n    # should / should not be caught. To use the original\r\n    # logic, call $default_handler->($exception, $catch_name)\r\n}\r\n```"}}