Skip to content

Commit

Permalink
#340 fix warning "'throw' inside 'catch' block which ignores the caug…
Browse files Browse the repository at this point in the history
…ht exception"
  • Loading branch information
asolntsev committed Jul 19, 2024
1 parent 8a05bf3 commit 17d27d5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ static NthChildCondition fromString(String number) {
Matcher m = pattern.matcher(number);

if (!m.matches()) {
throw new CSSParseException("Invalid nth-child selector: " + number, -1);
throw new CSSParseException("Invalid nth-child selector: " + number, -1, e);
} else {
int a = m.group(2).isEmpty() ? 1 : Integer.parseInt(m.group(2));
int b = (m.group(5) == null) ? 0 : Integer.parseInt(m.group(5));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
package org.xhtmlrenderer.css.parser;

public class CSSParseException extends RuntimeException {
private static final long serialVersionUID = 1L;

private final Token _found;
private final Token[] _expected;
private int _line;
Expand All @@ -31,6 +29,11 @@ public class CSSParseException extends RuntimeException {
private boolean _callerNotified;

public CSSParseException(String message, int line) {
this(message, line, null);
}

public CSSParseException(String message, int line, Throwable cause) {
super(message, cause);
_found = null;
_expected = null;
_line = line;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private void import_rule(Stylesheet stylesheet) throws IOException {
System.out.println("Token: " + tokenValue + " resolved " + resolvedUri);
info.setUri(resolvedUri);
} catch (URISyntaxException use) {
throw new CSSParseException("Invalid URL, " + use.getMessage(), getCurrentLine());
throw new CSSParseException("Invalid URL, " + use.getMessage(), getCurrentLine(), use);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ private BaseFont createFont(String name, String encoding, boolean embedded) {
return BaseFont.createFont(name, encoding, embedded);
}
catch (DocumentException | IOException e) {
throw new RuntimeException("Failed to load font " + name + " and encoding " + encoding);
throw new RuntimeException("Failed to load font " + name + " and encoding " + encoding, e);
}
}

Expand Down

0 comments on commit 17d27d5

Please sign in to comment.