android - How to handle exception and prevent crashing app -


i using amazon aws sdk download images s3. occasionally, when image not found exception "amazons3exception: status code: 404" thrown. however, seems exception should not crash app. how can handle exception not crash app? apologies, im noob java & android.

to follow on type-a1pha's answer:

if want handle exception gracefully, use try-catch statement. works this:

try {     // here put code may throw exception } catch (amazons3exception e) {     // looks errored out, log exception ,     // tell user 404'd     log.e(tag, "error fetching file amazon s3", e);     toast.maketext(context, "error 404 while fetching file: file not found", toast.length_short).show();     // insert other code need here recover error } {     // note part optional useful if want     // after try-catch statement finished     // example, if using inputstream:     inputstream.close(); } 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -