Reputation: 73
I have method search for exceptions
ValidationException(String operation) {
super("Not valid for operation " + checkOperation(operation));
}
And method for checking operation
private static String checkOperation(String operation) {
if (operation != null)
return operation;
else
return null;
}
If first method start working and operation == null
we have message "Not valid for operation null". But it must be "Not valid for operation". What need write instead of return null
?
Upvotes: 2
Views: 816
Reputation: 140318
Put the space into the return value of checkOperation
:
if (operation != null)
return " " + operation;
else
return "";
Then invoke like:
super("Not valid for operation" + checkOperation(operation));
// ^ remove the space here
Although I would consider it better to provide two overloads of the constructor:
Not valid for operation
);Not valid for operation whatever
).Upvotes: 5