A DESCRIPTION OF THE PROBLEM :
Please check below code snippet,
public void doSomething() throws AIProcessingException {
try {
sentimentClassification();
} catch (InterruptedException | ExecutionException e) {
throw new AIProcessingException(e);
}
}
If we do not catch InterruptedException, ExecutionException, we need to declare it on method signature.
But we don't want business code caller to handle these two exceptions, so we need to wrap it by business exception.
But similar code exist everywhere, which made the code not elegant.
Could we add a mechanism that wrapping up exceptions automatically by method declaration?
For example,
public void doSomething() throws AIProcessingException[InterruptedException, ExecutionException]
In this way, the method implementation would be simplified to:
public void doSomething() throws AIProcessingException[InterruptedException, ExecutionException] {
sentimentClassification();
}
Please check below code snippet,
public void doSomething() throws AIProcessingException {
try {
sentimentClassification();
} catch (InterruptedException | ExecutionException e) {
throw new AIProcessingException(e);
}
}
If we do not catch InterruptedException, ExecutionException, we need to declare it on method signature.
But we don't want business code caller to handle these two exceptions, so we need to wrap it by business exception.
But similar code exist everywhere, which made the code not elegant.
Could we add a mechanism that wrapping up exceptions automatically by method declaration?
For example,
public void doSomething() throws AIProcessingException[InterruptedException, ExecutionException]
In this way, the method implementation would be simplified to:
public void doSomething() throws AIProcessingException[InterruptedException, ExecutionException] {
sentimentClassification();
}