{"action":"closed","issue":{"url":"https://api.github.com/repos/mvdan/accesspoint/issues/3","labels_url":"https://api.github.com/repos/mvdan/accesspoint/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/mvdan/accesspoint/issues/3/comments","events_url":"https://api.github.com/repos/mvdan/accesspoint/issues/3/events","html_url":"https://github.com/mvdan/accesspoint/issues/3","id":102073502,"number":3,"title":"Only catch reflection exceptions","user":{"login":"pserwylo","id":248565,"avatar_url":"https://avatars.githubusercontent.com/u/248565?v=3","gravatar_id":"","url":"https://api.github.com/users/pserwylo","html_url":"https://github.com/pserwylo","followers_url":"https://api.github.com/users/pserwylo/followers","following_url":"https://api.github.com/users/pserwylo/following{/other_user}","gists_url":"https://api.github.com/users/pserwylo/gists{/gist_id}","starred_url":"https://api.github.com/users/pserwylo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pserwylo/subscriptions","organizations_url":"https://api.github.com/users/pserwylo/orgs","repos_url":"https://api.github.com/users/pserwylo/repos","events_url":"https://api.github.com/users/pserwylo/events{/privacy}","received_events_url":"https://api.github.com/users/pserwylo/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-20T06:44:39Z","updated_at":"2015-09-09T23:36:30Z","closed_at":"2015-09-09T23:36:30Z","body":"With regards to the API design, I'd suggest only catching the most specific exceptions that are relevant to you. For example, most of the methods which invoke methods via reflection do it like so:\r\n\r\n```\r\npublic boolean isWifiApEnabled() {\r\n\ttry {\r\n\t\treturn (Boolean) isWifiApEnabled.invoke(wm);\r\n\t} catch (Exception e) {\r\n\t\tLog.e(TAG, \"\", e);\r\n\t}\r\n\treturn false;\r\n}\r\n```\r\n\r\nI'd suggest only catching the exceptions to do with reflection. That way, if a genuine exception occurs inside one of the hidden API methods, then it will get thrown to the consumer of your API.\r\n\r\nThe tricky part is trying to identify if there are any checked exceptions (ones which _must_ be caught or thrown in the hidden API, because it may well differ depending on the version of Android which provides the API.\r\n\r\nI'm happy to submit pull requests for this and other issues I'll submit, just documenting now for prosterity."}}