Source:
<code>protected void onPostExecute(String result) { String refreshToken = null; String accessToken = null; int timeToExpireSecond = 3000; try { IdentityProxy identityProxy = IdentityProxy.getInstance(); if (responseCode != null && responseCode.equals(Constants.REQUEST_SUCCESSFUL)) { JSONObject response = new JSONObject(result); try { accessToken = response.getString(Constants.ACCESS_TOKEN); refreshToken = response.getString(Constants.REFRESH_TOKEN); timeToExpireSecond = Integer.parseInt(response.getString(Constants.EXPIRE_LABEL)); Token token = new Token(); token.setDate(); token.setRefreshToken(refreshToken); token.setAccessToken(accessToken); token.setExpired(false); SharedPreferences mainPref = IdentityProxy.getInstance() .getContext() .getSharedPreferences(Constants.APPLICATION_PACKAGE, Context.MODE_PRIVATE); Editor editor = mainPref.edit(); editor.putString(Constants.ACCESS_TOKEN, accessToken); editor.putString(Constants.REFRESH_TOKEN, refreshToken); editor.putString(USERNAME_LABEL, info.getUsername()); Date date = new Date(); long expiresIN = date.getTime() + (timeToExpireSecond * 1000); Date expireDate = new Date(expiresIN); String strDate = dateFormat.format(expireDate); token.setDate(strDate); editor.putString(Constants.DATE_LABEL, strDate); editor.commit(); identityProxy.receiveAccessToken(responseCode, Constants.SUCCESS_RESPONSE, token); } catch (JSONException e) { Log.e(TAG, "Invalid JSON format."); } } else if (responseCode != null) { if (Constants.INTERNAL_SERVER_ERROR.equals(responseCode)) { identityProxy.receiveAccessToken(responseCode, result, null); } else { JSONObject mainObject = new JSONObject(result); String errorDescription = mainObject.getString(Constants.ERROR_DESCRIPTION_LABEL); identityProxy.receiveAccessToken(responseCode, errorDescription, null); } } } catch (JSONException e) { <START> Log.e(TAG, "Invalid JSON." + e); <END> } }</code><technical_language>compressed error messages more consistent code. For example, I some of error messages carry exception "cause" appended contents some don't</technical_language>

Target:
protected void onPostExecute(String result) { String refreshToken = null; String accessToken = null; int timeToExpireSecond = 3000; try { IdentityProxy identityProxy = IdentityProxy.getInstance(); if (responseCode != null && responseCode.equals(Constants.REQUEST_SUCCESSFUL)) { JSONObject response = new JSONObject(result); try { accessToken = response.getString(Constants.ACCESS_TOKEN); refreshToken = response.getString(Constants.REFRESH_TOKEN); timeToExpireSecond = Integer.parseInt(response.getString(Constants.EXPIRE_LABEL)); Token token = new Token(); Date date = new Date(); String currentDate = dateFormat.format(date); token.setDate(currentDate); token.setRefreshToken(refreshToken); token.setAccessToken(accessToken); token.setExpired(false); SharedPreferences mainPref = IdentityProxy.getInstance() .getContext() .getSharedPreferences(Constants.APPLICATION_PACKAGE, Context.MODE_PRIVATE); Editor editor = mainPref.edit(); editor.putString(Constants.ACCESS_TOKEN, accessToken); editor.putString(Constants.REFRESH_TOKEN, refreshToken); editor.putString(USERNAME_LABEL, info.getUsername()); long expiresIN = date.getTime() + (timeToExpireSecond * 1000); Date expireDate = new Date(expiresIN); String strDate = dateFormat.format(expireDate); token.setDate(strDate); editor.putString(Constants.DATE_LABEL, strDate); editor.commit(); identityProxy.receiveAccessToken(responseCode, Constants.SUCCESS_RESPONSE, token); } catch (JSONException e) { Log.e(TAG, "Invalid JSON format." + e); } } else if (responseCode != null) { if (Constants.INTERNAL_SERVER_ERROR.equals(responseCode)) { identityProxy.receiveAccessToken(responseCode, result, null); } else { JSONObject mainObject = new JSONObject(result); String errorDescription = mainObject.getString(Constants.ERROR_DESCRIPTION_LABEL); identityProxy.receiveAccessToken(responseCode, errorDescription, null); } } } catch (JSONException e) { Log.e(TAG, "Invalid JSON." + e); } }