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

If there is no piece on the source square inside Board.isMoveLegal(move, fullValidation) method, then return false instead of throwing exception #121

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sourashis59
Copy link

Fix: Return false instead of throwing RuntimeException for invalid moves for one case

In the Board.isMoveLegal(move, fullValidation) method, if the from 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.

…ve, fullValidation) method, then return false instead of throwing exception
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

Successfully merging this pull request may close these issues.

1 participant