Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSProcessor and SAXProcessor exception handling improvement #25

Open
bernard01 opened this issue Aug 8, 2017 · 0 comments
Open

TSProcessor and SAXProcessor exception handling improvement #25

bernard01 opened this issue Aug 8, 2017 · 0 comments

Comments

@bernard01
Copy link

bernard01 commented Aug 8, 2017

Ideally, create and throw SAXRuntimeException.

In the following case, a checked exception is thrown on a condition similar to where typically java.lang.IndexOutOfBoundsException is thrown.

However IndexOutOfBoundsException extends RuntimeException.

There is little chance in the following case to meaningfully catch the checked exception and recover from it. Once it is thrown, it is game over because of a programming error.

SAXProcessor
public char[] ts2string(double[] ts, int paaSize, double[] cuts, double nThreshold)
throws SAXException {

throws it because it calls

TSProcessor
public double[] paa(double[] ts, int paaSize) throws SAXException {
if (len < paaSize) {
throw new SAXException("PAA size can't be greater than the timeseries size.");
}

What one ends up doing as a developer using this library is to ring fence the exception in a way like this:

final char[] ts2string;
try {
ts2string = sp.ts2string(windowSubseries, paaSize, na.getCuts(alphabetSize), normalizationThreshold);
} catch (SAXException ex) {
throw new RuntimeException(ex);
}

which disrupts the work flow when writing software.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant