In particular, is there a standard Exception subclass used in these circumstances?
In particular, is there a standard Exception subclass used in these circumstances?
java.lang.UnsupportedOperationException
Thrown to indicate that the requested operation is not supported.
If you want more granularity and better description, you could use NotImplementedException from commons-lang
Warning: Available before versions 2.6 and after versions 3.2 only.
The below Calculator sample class shows the difference
public class Calculator() {
int add(int a , int b){
return a+b;
}
int dived(int a , int b){
if ( b == 0 ) {
throw new UnsupportedOperationException("I can not dived by zero,
not now not for the rest of my life!")
}else{
return a/b;
}
}
int multiple(int a , int b){
//NotImplementedException from apache or some custom excpetion
throw new NotImplementedException("Will be implement in release 3.5");
}
}