Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Adjust logging level for failed OkHttp requests #6378

Merged
merged 2 commits into from
Sep 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.text.TextUtils;
import android.util.Log;

import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.exceptions.InvalidAccessTokenException;
Expand Down Expand Up @@ -94,7 +93,6 @@ public boolean isConnected() {
ConnectivityManager cm = (ConnectivityManager) applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean result = (activeNetwork != null && activeNetwork.isConnected());
Log.v("IOUtils", "isConnected result = " + result);
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ public void onFailure(Call call, IOException e) {
}

private void onFailure(Exception e) {
Log.w(LOG_TAG, String.format("[HTTP] Request could not be executed: %s", e.getMessage()));

int type = PERMANENT_ERROR;
if ((e instanceof NoRouteToHostException) || (e instanceof UnknownHostException) || (e instanceof SocketException) || (e instanceof ProtocolException) || (e instanceof SSLException)) {
type = CONNECTION_ERROR;
Expand All @@ -149,6 +147,18 @@ private void onFailure(Exception e) {

String errorMessage = e.getMessage() != null ? e.getMessage() : "Error processing the request";

if (type == TEMPORARY_ERROR) {
Log.d(LOG_TAG, String.format(MapboxConstants.MAPBOX_LOCALE,
"Request failed due to a temporary error: %s", errorMessage));
} else if (type == CONNECTION_ERROR) {
Log.i(LOG_TAG, String.format(MapboxConstants.MAPBOX_LOCALE,
"Request failed due to a connection error: %s", errorMessage));
} else {
// PERMANENT_ERROR
Log.w(LOG_TAG, String.format(MapboxConstants.MAPBOX_LOCALE,
"Request failed due to a permanent error: %s", errorMessage));
}

mLock.lock();
if (mNativePtr != 0) {
nativeOnFailure(type, errorMessage);
Expand Down