Skip to content

Commit

Permalink
Fix exception message can be null (#1133)
Browse files Browse the repository at this point in the history
  • Loading branch information
devemux86 authored Jul 25, 2024
1 parent 596337d commit 80f1d45
Show file tree
Hide file tree
Showing 38 changed files with 72 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public boolean accept(File file) {
ThemeLoader.load(file.getAbsolutePath());
mOpenResult = OpenResult.SUCCESS;
} catch (Exception e) {
mOpenResult = new OpenResult(e.getMessage());
mOpenResult = new OpenResult(e.toString());
}
return mOpenResult.isSuccess();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void onClick(DialogInterface dialog, int which) {
} catch (MBTilesUnsupportedException e) {
AlertDialog.Builder builder = new AlertDialog.Builder(this)
.setTitle(R.string.warning)
.setMessage(e.getMessage())
.setMessage(e.toString())
.setPositiveButton(R.string.exit, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
mPrefs.clear();
}
} catch (Exception e) {
log.error(e.getMessage());
log.error(e.toString());
finish();
}
} else if (requestCode == SELECT_THEME_ARCHIVE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ protected Collection<PointOfInterest> doInBackground(BoundingBox... params) {
params[0].getMaxLatitude(), params[0].getMaxLongitude());
return mPersistenceManager.findInRect(bb, categoryFilter, patterns, null, Integer.MAX_VALUE, true);
} catch (Throwable t) {
log.error(t.getMessage(), t);
log.error(t.toString(), t);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void query(MapTile requestTile, ITileDataSink requestDataSink) {
} else
responseDataSink.completed(QueryResult.TILE_NOT_FOUND);
} catch (Throwable t) {
log.error(t.getMessage(), t);
log.error(t.toString(), t);
responseDataSink.completed(QueryResult.FAILED);
} finally {
if (cursor != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public InputStream getRenderThemeAsStream() throws ThemeException {
try {
return mAssetManager.open((TextUtils.isEmpty(mRelativePathPrefix) ? "" : mRelativePathPrefix) + mFileName);
} catch (IOException e) {
throw new ThemeException(e.getMessage(), e);
throw new ThemeException(e.toString(), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public InputStream getRenderThemeAsStream() throws ThemeException {
try {
return mContentResolver.openInputStream(mUri);
} catch (IOException e) {
throw new ThemeException(e.getMessage(), e);
throw new ThemeException(e.toString(), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void query(MapTile tile, ITileDataSink sink) {
sink.setTileImage(bitmap);
res = QueryResult.SUCCESS;
} catch (Throwable t) {
log.error(t.getMessage(), t);
log.error(t.toString(), t);
} finally {
sink.completed(res);
}
Expand Down
2 changes: 1 addition & 1 deletion vtm-app/src/org/oscim/app/filefilter/ValidRenderTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public boolean accept(File file) {
ThemeLoader.load(file.getAbsolutePath());
mOpenResult = OpenResult.SUCCESS;
} catch (Exception e) {
mOpenResult = new OpenResult(e.getMessage());
mOpenResult = new OpenResult(e.toString());
}
return mOpenResult.isSuccess();
}
Expand Down
2 changes: 1 addition & 1 deletion vtm-desktop/src/org/oscim/awt/AwtBitmap.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public byte[] getPngEncodedData() {
ImageIO.write(this.bitmap, "png", outputStream);
return outputStream.toByteArray();
} catch (IOException e) {
log.error(e.getMessage(), e);
log.error(e.toString(), e);
} finally {
IOUtils.closeQuietly(outputStream);
}
Expand Down
2 changes: 1 addition & 1 deletion vtm-gdx/src/org/oscim/gdx/GdxAssets.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public InputStream openFileAsStream(String fileName) {
try {
return file.read();
} catch (GdxRuntimeException e) {
log.debug(e.getMessage());
log.debug(e.toString());
return null;
}
}
Expand Down
6 changes: 3 additions & 3 deletions vtm-http/src/org/oscim/tiling/source/OkHttpEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void sendRequest(Tile tile) throws IOException {
} else
mInputStream = response.body().byteStream();
} catch (Exception e) {
log.error(e.getMessage(), e);
log.error(e.toString(), e);
}
}

Expand All @@ -101,7 +101,7 @@ public void close() {
try {
mInputStream.close();
} catch (Exception e) {
log.error(e.getMessage(), e);
log.error(e.toString(), e);
}
mInputStream = null;
}
Expand All @@ -112,7 +112,7 @@ public void setCache(OutputStream os) {
try {
os.write(mCachedData);
} catch (IOException e) {
log.error(e.getMessage(), e);
log.error(e.toString(), e);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion vtm-ios/src/org/oscim/ios/backend/IosSvgBitmap.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private static String getStringFromInputStream(InputStream is) {
sb.append(line);
}
} catch (IOException e) {
log.error(e.getMessage(), e);
log.error(e.toString(), e);
} finally {
IOUtils.closeQuietly(br);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void setupLoop() {
listener.create();
listener.resize(graphics.getWidth(), graphics.getHeight());
} catch (Throwable t) {
error("GwtApplication", "exception: " + t.getMessage(), t);
error("GwtApplication", "exception: " + t.toString(), t);
t.printStackTrace();
throw new RuntimeException(t);
}
Expand All @@ -207,7 +207,7 @@ public void execute(double timestamp) {
try {
mainLoop();
} catch (Throwable t) {
error("GwtApplication", "exception: " + t.getMessage(), t);
error("GwtApplication", "exception: " + t.toString(), t);
throw new RuntimeException(t);
}
AnimationScheduler.get().requestAnimationFrame(this, graphics.canvas);
Expand Down Expand Up @@ -343,7 +343,7 @@ public void log(String tag, String message, Throwable exception) {
checkLogLabel();
log.setText(log.getText() + "\n" + tag + ": " + message + "\n" + getMessages(exception) + "\n");
log.setCursorPos(log.getText().length() - 1);
System.out.println(tag + ": " + message + "\n" + exception.getMessage());
System.out.println(tag + ": " + message + "\n" + exception.toString());
System.out.println(getStackTrace(exception));
}
}
Expand All @@ -364,7 +364,7 @@ public void error(String tag, String message, Throwable exception) {
checkLogLabel();
log.setText(log.getText() + "\n" + tag + ": " + message + "\n" + getMessages(exception) + "\n");
log.setCursorPos(log.getText().length() - 1);
System.err.println(tag + ": " + message + "\n" + exception.getMessage() + "\n");
System.err.println(tag + ": " + message + "\n" + exception.toString() + "\n");
System.out.println(getStackTrace(exception));
}
}
Expand All @@ -385,15 +385,15 @@ public void debug(String tag, String message, Throwable exception) {
checkLogLabel();
log.setText(log.getText() + "\n" + tag + ": " + message + "\n" + getMessages(exception) + "\n");
log.setCursorPos(log.getText().length() - 1);
System.out.println(tag + ": " + message + "\n" + exception.getMessage());
System.out.println(tag + ": " + message + "\n" + exception.toString());
System.out.println(getStackTrace(exception));
}
}

private String getMessages(Throwable e) {
StringBuffer buffer = new StringBuffer();
while (e != null) {
buffer.append(e.getMessage() + "\n");
buffer.append(e.toString() + "\n");
e = e.getCause();
}
return buffer.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static IRenderTheme read(ThemeFile theme, ThemeCallback themeCallback) th
try {
new XMLReaderAdapter().parse(renderThemeHandler, theme.getRenderThemeAsStream());
} catch (Exception e) {
throw new ThemeException(e.getMessage(), e);
throw new ThemeException(e.toString(), e);
}

TextureAtlasUtils.createTextureRegions(renderThemeHandler.bitmapMap, outputMap, atlasList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static IRenderTheme read(ThemeFile theme, ThemeCallback themeCallback) th
try {
new XMLReaderAdapter().parse(renderThemeHandler, theme.getRenderThemeAsStream());
} catch (Exception e) {
throw new ThemeException(e.getMessage(), e);
throw new ThemeException(e.toString(), e);
}

return renderThemeHandler.mRenderTheme;
Expand Down Expand Up @@ -236,12 +236,12 @@ public void endElement(String uri, String localName, String qName) {

@Override
public void error(SAXParseException exception) {
log.debug(exception.getMessage());
log.debug(exception.toString());
}

@Override
public void warning(SAXParseException exception) {
log.debug(exception.getMessage());
log.debug(exception.toString());
}

@Override
Expand Down Expand Up @@ -385,9 +385,9 @@ public void startElement(String uri, String localName, String qName,
throw new SAXException("unknown element: " + localName);
}
} catch (SAXException e) {
throw new ThemeException(e.getMessage(), e);
throw new ThemeException(e.toString(), e);
} catch (IOException e) {
throw new ThemeException(e.getMessage(), e);
throw new ThemeException(e.toString(), e);
}
}

Expand Down Expand Up @@ -1103,7 +1103,7 @@ else if ("position".equals(name)) {
try {
b.bitmap = CanvasAdapter.getBitmapAsset(mTheme.getRelativePathPrefix(), symbol, mTheme.getResourceProvider(), b.symbolWidth, b.symbolHeight, b.symbolPercent);
} catch (Exception e) {
log.error("{}: {}", symbol, e.getMessage());
log.error("{}: {}", symbol, e.toString());
}
} else
b.texture = getAtlasRegion(symbol);
Expand Down Expand Up @@ -1251,7 +1251,7 @@ private SymbolStyle buildSymbol(SymbolBuilder<?> b) {
if (bitmap != null)
return buildSymbol(b, b.src, bitmap);
} catch (Exception e) {
log.error("{}: {}", b.src, e.getMessage());
log.error("{}: {}", b.src, e.toString());
}
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions vtm-web/src/org/oscim/gdx/emu/org/oscim/utils/IOUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static void closeQuietly(OutputStream closeable) {
closeable.close();
}
} catch (IOException e) {
//log.debug(e.getMessage() + " " + e);
//log.debug(e.toString() + " " + e);
}
}

Expand All @@ -48,7 +48,7 @@ public static void closeQuietly(InputStream closeable) {
closeable.close();
}
} catch (IOException e) {
//log.debug(e.getMessage() + " " + e);
//log.debug(e.toString() + " " + e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ public XmlPullParserException(String msg, XmlPullParser parser, Throwable chain)
/*
public String getMessage() {
if(detail == null)
return super.getMessage();
return super.toString();
else
return super.getMessage() + "; nested exception is: \n\t"
+ detail.getMessage();
return super.toString() + "; nested exception is: \n\t"
+ detail.toString();
}
*/

Expand All @@ -66,7 +66,7 @@ public void printStackTrace() {
super.printStackTrace();
} else {
synchronized(System.err) {
System.err.println(super.getMessage() + "; nested exception is:");
System.err.println(super.toString() + "; nested exception is:");
detail.printStackTrace();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void doGet(final String url) {
public void onFailure(Throwable caught) {

mSink.completed(FAILED);
log.debug("fail! {} {}", mRequestHandle, caught.getMessage());
log.debug("fail! {} {}", mRequestHandle, caught.toString());
//mRequestHandle.cancel();
}

Expand Down
2 changes: 1 addition & 1 deletion vtm/src/org/oscim/layers/tile/bitmap/BitmapTileLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected boolean loadTile(MapTile tile) {
try {
mTileDataSource.query(tile, this);
} catch (Exception e) {
log.debug("{} {}", tile, e.getMessage());
log.debug("{} {}", tile, e.toString());
return false;
}
return true;
Expand Down
4 changes: 2 additions & 2 deletions vtm/src/org/oscim/layers/tile/vector/VectorTileLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ public boolean loadTile(MapTile tile) {
/* query data source, which calls process() callback */
mTileDataSource.query(tile, this);
} catch (NullPointerException e) {
log.debug("NPE {} {}", tile, e.getMessage());
log.debug("NPE {} {}", tile, e.toString());
e.printStackTrace();
} catch (Throwable t) {
log.debug("{} {}", tile, t.getMessage());
log.debug("{} {}", tile, t.toString());
t.printStackTrace();
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion vtm/src/org/oscim/map/Layers.java
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ public synchronized void updateLayers() {

mDirtyLayers = false;
} catch (Exception e) {
log.error(e.getMessage(), e);
log.error(e.toString(), e);
}
}
}
2 changes: 1 addition & 1 deletion vtm/src/org/oscim/renderer/MapRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void onDrawFrame() {
try {
draw();
} catch (Throwable t) {
log.error(t.getMessage(), t);
log.error(t.toString(), t);
}

mMap.doneFrame(rerender);
Expand Down
2 changes: 1 addition & 1 deletion vtm/src/org/oscim/theme/ExternalRenderTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public InputStream getRenderThemeAsStream() throws ThemeException {
try {
is = new FileInputStream(mPath);
} catch (FileNotFoundException e) {
throw new ThemeException(e.getMessage(), e);
throw new ThemeException(e.toString(), e);
}
return is;
}
Expand Down
2 changes: 1 addition & 1 deletion vtm/src/org/oscim/theme/ThemeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void startElement(String uri, String localName, String qName, Attributes
}
return isMapsforgeTheme.get();
} catch (Exception e) {
log.error(e.getMessage(), e);
log.error(e.toString(), e);
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion vtm/src/org/oscim/theme/XmlAtlasThemeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static IRenderTheme read(ThemeFile theme, ThemeCallback themeCallback) th
true, CanvasAdapter.platform == Platform.IOS);
return replaceThemeSymbols(renderThemeHandler.mRenderTheme, outputMap);
} catch (Exception e) {
throw new ThemeException(e.getMessage(), e);
throw new ThemeException(e.toString(), e);
} finally {
IOUtils.closeQuietly(inputStream);
}
Expand Down
Loading

0 comments on commit 80f1d45

Please sign in to comment.