Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to catch android.content.res.Resources$NotFoundException

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?

like image 359
zooter Avatar asked Feb 07 '23 06:02

zooter


1 Answers

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.

like image 140
Mike M. Avatar answered Feb 09 '23 19:02

Mike M.