Android Build a Weather App Concurrency and Error Handling Configuring the AlertDialog

remi poolen
remi poolen
5,325 Points

error: exception IOException is never thrown in body of corresponding try statement

i followed along with the video, making a weather app. but on the onResponse method of a CallBack i get the above error.

Code:

    Call call = client.newCall(request);
    call.enqueue(new Callback() {
        @Override
        public void onFailure(Call call, IOException e) {

        }

        @Override
        public void onResponse(Call call, Response response) throws IOException  {
            Log.v(TAG, response.body().string());
            try {
                if (response.isSuccessful()) {

                }
                else {
                    alertUserAboutError();
                }
            } catch (IOException e) {
                Log.e(TAG, "IO Exception caught", e);
            }
        }
    });