package com.example.apollographql.sample;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.TextView;

import com.apollographql.apollo.ApolloCall;
import com.apollographql.apollo.api.Response;
import com.example.FeedQuery;
import com.example.type.FeedType;

import javax.annotation.Nonnull;

public class MainActivity extends AppCompatActivity {
  private static final String TAG = "MainActivity";

  private SampleApplication application;

  @Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final TextView txtResponse = (TextView) findViewById(R.id.txt_response);
    application = (SampleApplication) getApplication();

    application.apolloClient().newCall(FeedQuery.builder()
        .limit(10)
        .type(FeedType.HOT)
        .build()).enqueue(new ApolloCall.Callback<FeedQuery.Data>() {

      @Override public void onResponse(@Nonnull Response<FeedQuery.Data> dataResponse) {

        final StringBuffer buffer = new StringBuffer();
        for (FeedQuery.Data.Feed feed : dataResponse.data().feed()) {
          buffer.append("name:" + feed.repository().fragments().repositoryFragment().name());
          buffer.append(" owner: " + feed.repository().fragments().repositoryFragment().owner().login());
          buffer.append(" postedBy: " + feed.postedBy().login());
          buffer.append("\n~~~~~~~~~~~");
          buffer.append("\n\n");
        }

        MainActivity.this.runOnUiThread(new Runnable() {
          @Override public void run() {
            txtResponse.setText(buffer.toString());
          }
        });

      }

      @Override public void onFailure(@Nonnull Throwable t) {
        Log.e(TAG, t.getMessage(), t);
      }
    });
  }

}


@@ -259,16 +259,75 @@
 sponse;%0A
+import com.apollographql.apollo.exception.ApolloException;%0A
 import c
@@ -1828,19 +1828,25 @@
 ull 
-Throwable t
+ApolloException e
 ) %7B%0A
@@ -1864,17 +1864,17 @@
 .e(TAG, 
-t
+e
 .getMess
@@ -1880,17 +1880,17 @@
 sage(), 
-t
+e
 );%0A     

Fix the compilation error by overriding the correct onFailure (#387)