{"action":"created","issue":{"url":"https://api.github.com/repos/Codearte/catch-exception/issues/23","labels_url":"https://api.github.com/repos/Codearte/catch-exception/issues/23/labels{/name}","comments_url":"https://api.github.com/repos/Codearte/catch-exception/issues/23/comments","events_url":"https://api.github.com/repos/Codearte/catch-exception/issues/23/events","html_url":"https://github.com/Codearte/catch-exception/issues/23","id":66305976,"number":23,"title":"Catch exceptions directly in the expected type","user":{"login":"sedubois","id":4217871,"avatar_url":"https://avatars.githubusercontent.com/u/4217871?v=3","gravatar_id":"","url":"https://api.github.com/users/sedubois","html_url":"https://github.com/sedubois","followers_url":"https://api.github.com/users/sedubois/followers","following_url":"https://api.github.com/users/sedubois/following{/other_user}","gists_url":"https://api.github.com/users/sedubois/gists{/gist_id}","starred_url":"https://api.github.com/users/sedubois/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sedubois/subscriptions","organizations_url":"https://api.github.com/users/sedubois/orgs","repos_url":"https://api.github.com/users/sedubois/repos","events_url":"https://api.github.com/users/sedubois/events{/privacy}","received_events_url":"https://api.github.com/users/sedubois/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-04-04T11:08:03Z","updated_at":"2015-04-05T19:24:22Z","closed_at":"2015-04-05T19:24:22Z","body":"I have a custom `BusinessRuleException` with an extra method `getCode()`. With catch-exception 1.4.2, my tests look like this (didn't find a better way):\r\n\r\n```\r\nwhen(service).doSomething();\r\n\r\nthen(caughtException()).isInstanceOf(BusinessRuleException.class);\r\nBusinessRuleException e = (BusinessRuleException) caughtException();\r\nthen(e.getCode()).isEqualTo(MY_ERROR_CODE);\r\n```\r\n\r\nThis has 2 issues:\r\n- on the third line, where `caughtException()` is called, IntelliJ IDEA 14.1 warns that I get an exception which is not rethrown\r\n- not fluent\r\n\r\nI would expect to be able to write something like (or some variation with better API and taking into account what's required to avoid unchecked casts and whatnot):\r\n\r\n```\r\nwhen(service).doSomething();\r\n\r\nthen(caughtException())\r\n    .isInstanceOfAndGet(BusinessRuleException.class)\r\n    .getCode().isEqualTo(MY_ERROR_CODE);\r\n```"},"comment":{"url":"https://api.github.com/repos/Codearte/catch-exception/issues/comments/89836251","html_url":"https://github.com/Codearte/catch-exception/issues/23#issuecomment-89836251","issue_url":"https://api.github.com/repos/Codearte/catch-exception/issues/23","id":89836251,"user":{"login":"mariuszs","id":1623393,"avatar_url":"https://avatars.githubusercontent.com/u/1623393?v=3","gravatar_id":"","url":"https://api.github.com/users/mariuszs","html_url":"https://github.com/mariuszs","followers_url":"https://api.github.com/users/mariuszs/followers","following_url":"https://api.github.com/users/mariuszs/following{/other_user}","gists_url":"https://api.github.com/users/mariuszs/gists{/gist_id}","starred_url":"https://api.github.com/users/mariuszs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mariuszs/subscriptions","organizations_url":"https://api.github.com/users/mariuszs/orgs","repos_url":"https://api.github.com/users/mariuszs/repos","events_url":"https://api.github.com/users/mariuszs/events{/privacy}","received_events_url":"https://api.github.com/users/mariuszs/received_events","type":"User","site_admin":false},"created_at":"2015-04-05T19:24:22Z","updated_at":"2015-04-05T19:24:22Z","body":"Fixed in #27 "}}