Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
tariqasgharUX Design Techdegree Graduate 30,519 Points
try catch IOException and throws IOException on the same method.
In the "Introducing JSONObject" video on "Build a weather app" course in android track, the onResponse method throws IOException but is also catching the IOException. Shouldn't the method calling onResponse catch the IOException??
Seth Kroger56,412 Points
The method calling onResponse() is somewhere in the depths of the okhttp library. Just letting the library deal with it may sound okay but there was still an error in getting the forecast. It's better for our app deal with the error and take the appropriate action instead of ignoring it. Catching the IOException allows us to do that.