If there is no piece on the source square inside Board.isMoveLegal(move, fullValidation)
method, then return false instead of throwing exception
#121
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix: Return false instead of throwing
RuntimeException
for invalid moves for one caseIn the
Board.isMoveLegal(move, fullValidation)
method, if thefrom
square of the given move is empty, a RuntimeException was being thrown. This PR change modifies the behavior to return false instead.The expected behavior for the case should be to return false instead of throwing runtime exception, as the source (or from) square of the given move does not have any piece, hence making the move invalid. Throwing exception for this particular case is not expected from client side and handling runtime exception is problematic in client code. So returning
false
here should be a better option than throwing exception.