Skip to content

Commit

Permalink
[refactor] FunReplace and FunAnalyzeString
Browse files Browse the repository at this point in the history
- use enhanced switch for readability
- add general error code to default case
  • Loading branch information
line-o committed Apr 26, 2023
1 parent 1cfe2c1 commit 5f97429
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,10 @@ private void analyzeString(final MemTreeBuilder builder, final String input, Str
}
} catch (final net.sf.saxon.trans.XPathException e) {
switch (e.getErrorCodeLocalPart()) {
case "FORX0001":
throw new XPathException(this, ErrorCodes.FORX0001, e.getMessage());
case "FORX0002":
throw new XPathException(this, ErrorCodes.FORX0002, e.getMessage());
case "FORX0003":
throw new XPathException(this, ErrorCodes.FORX0003, e.getMessage());
default:
throw new XPathException(this, e.getMessage());
case "FORX0001" -> throw new XPathException(this, ErrorCodes.FORX0001, e.getMessage());
case "FORX0002" -> throw new XPathException(this, ErrorCodes.FORX0002, e.getMessage());
case "FORX0003" -> throw new XPathException(this, ErrorCodes.FORX0003, e.getMessage());
default -> throw new XPathException(this, e.getMessage());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,11 @@ public Sequence eval(final Sequence[] args, final Sequence contextSequence) thro

} catch (final net.sf.saxon.trans.XPathException e) {
switch (e.getErrorCodeLocalPart()) {
case "FORX0001":
throw new XPathException(this, ErrorCodes.FORX0001, e.getMessage());
case "FORX0002":
throw new XPathException(this, ErrorCodes.FORX0002, e.getMessage());
case "FORX0003":
throw new XPathException(this, ErrorCodes.FORX0003, e.getMessage());
case "FORX0004":
throw new XPathException(this, ErrorCodes.FORX0004, e.getMessage());
default:
throw new XPathException(this, e.getMessage());
case "FORX0001" -> throw new XPathException(this, ErrorCodes.FORX0001, e.getMessage());
case "FORX0002" -> throw new XPathException(this, ErrorCodes.FORX0002, e.getMessage());
case "FORX0003" -> throw new XPathException(this, ErrorCodes.FORX0003, e.getMessage());
case "FORX0004" -> throw new XPathException(this, ErrorCodes.FORX0004, e.getMessage());
default -> throw new XPathException(this, ErrorCodes.ERROR, e.getMessage());
}
}
}
Expand Down

0 comments on commit 5f97429

Please sign in to comment.