Skip to content

Commit

Permalink
Theme exception improvements (#1083)
Browse files Browse the repository at this point in the history
  • Loading branch information
devemux86 authored Dec 16, 2023
1 parent 8723875 commit 64df148
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 13 deletions.
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());
throw new ThemeException(e.getMessage(), 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());
throw new ThemeException(e.getMessage(), e);
}
}

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());
throw new ThemeException(e.getMessage(), 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());
throw new ThemeException(e.getMessage(), e);
}

return renderThemeHandler.mRenderTheme;
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());
throw new ThemeException(e.getMessage(), e);
} catch (IOException e) {
throw new ThemeException(e.getMessage());
throw new ThemeException(e.getMessage(), e);
}
}

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());
throw new ThemeException(e.getMessage(), e);
}
return is;
}
Expand Down
8 changes: 6 additions & 2 deletions vtm/src/org/oscim/theme/IRenderTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,12 @@ public interface IRenderTheme {
Tag transformForwardTag(Tag tag);

class ThemeException extends IllegalArgumentException {
public ThemeException(String string) {
super(string);
public ThemeException(String message) {
super(message);
}

public ThemeException(String message, Throwable cause) {
super(message, cause);
}

private static final long serialVersionUID = 1L;
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());
throw new ThemeException(e.getMessage(), e);
} finally {
IOUtils.closeQuietly(inputStream);
}
Expand Down
4 changes: 2 additions & 2 deletions vtm/src/org/oscim/theme/XmlThemeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public static IRenderTheme read(ThemeFile theme, ThemeCallback themeCallback) th
renderThemeHandler.processRenderTheme();
return renderThemeHandler.mRenderTheme;
} catch (Exception e) {
throw new ThemeException(e.getMessage());
throw new ThemeException(e.getMessage(), e);
} finally {
IOUtils.closeQuietly(inputStream);
}
Expand Down Expand Up @@ -409,7 +409,7 @@ public void startElement() throws ThemeException {
throw new XmlPullParserException("unknown element: " + qName);
}
} catch (XmlPullParserException | IOException e) {
throw new ThemeException(e.getMessage());
throw new ThemeException(e.getMessage(), e);
}
}

Expand Down
2 changes: 1 addition & 1 deletion vtm/src/org/oscim/theme/ZipRenderTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public InputStream getRenderThemeAsStream() throws ThemeException {
try {
return mResourceProvider.createInputStream(mRelativePathPrefix, mXmlTheme.substring(mXmlTheme.lastIndexOf("/") + 1));
} catch (IOException e) {
throw new ThemeException(e.getMessage());
throw new ThemeException(e.getMessage(), e);
}
}

Expand Down

0 comments on commit 64df148

Please sign in to comment.