Skip to content

Commit

Permalink
Add more details to error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Hawazine H committed Feb 24, 2017
1 parent 16d950a commit 088ebca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Expand Up @@ -16,6 +16,7 @@
class GalleryAdapter extends BaseAdapter {

private static final String TAG = "GalleryAdapter";
private static final String PLACEHOLDER_FILE = "placeholder.png";
private final Context mContext;

public GalleryAdapter(Context c) {
Expand Down Expand Up @@ -48,10 +49,10 @@ public View getView(int position, View convertView, ViewGroup parent) {

Bitmap image = null;
try {
InputStream bitmap = mContext.getAssets().open("placeholder.png");
InputStream bitmap = mContext.getAssets().open(PLACEHOLDER_FILE);
image = BitmapFactory.decodeStream(bitmap);
} catch (IOException exception) {
Log.e(TAG, "Something happen when you have tried to open the file placeholder.png", exception);
Log.e(TAG, "An error occurred when you have tried to open the file: "+ PLACEHOLDER_FILE, exception);
}

imageView.setImageBitmap(image);
Expand Down
Expand Up @@ -71,17 +71,17 @@ private InputStream retrieveStream(String url) {
final int statusCode = getResponse.getStatusLine().getStatusCode();

if (statusCode != HttpStatus.SC_OK) {
Log.w(getClass().getSimpleName(), "Error " + statusCode + " for URL " + url);
Log.w(getClass().getSimpleName(), "An error occurred with this URL: " + url + " Http status code: " + statusCode);
return null;
}

HttpEntity getResponseEntity = getResponse.getEntity();
return getResponseEntity.getContent();

}
}
catch (IOException e) {
getRequest.abort();
Log.e(TAG, "Error for URL " + url, e);
Log.e(TAG, "An error occurred with this URL: " + url, e);
}
return null;
}
Expand Down

0 comments on commit 088ebca

Please sign in to comment.