Reputation: 2208
Sorry if this is a dumb question, but how do I catch this particular exception in my code? i.e, in my Catch block, what should be the catch keyword?
Upvotes: 5
Views: 2367
Reputation: 39191
You can use catch(Resources.NotFoundException e)
. The $
in your stack trace just means NotFoundException
is a nested class in Resources
.
You could import the fully qualified class for NotFoundException
- that is, android.content.res.Resources.NotFoundException
- and just use NotFoundException
in the catch
, but it's arguably better for readability and comprehension to include the containing class for such a generically named Exception
.
Upvotes: 9
Reputation: 13785
try {
drawable = Resources.getSystem().getDrawable(R.drawable.icon);
} catch (NotFoundException e) {
e.printStackTrace();
}
Upvotes: 0