You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to toss this suggestion in the mix before 1.0.0 is released. 🙂
It'd be great if Chess.js could throw a specific error type if an illegal move is made, rather than a generic error. Then, detecting an illegal move could look something like this:
functionreduceLegalMove(fen: string,{ from, to }: MoveEvent): string{constchess=newChess(fen);try{chess.move({ from, to });}catch(error){if(errorinstanceofIllegalMoveError){returnfen;}throwerror;}returnchess.fen();}
The text was updated successfully, but these errors were encountered:
I wanted to toss this suggestion in the mix before 1.0.0 is released. 🙂
It'd be great if Chess.js could throw a specific error type if an illegal move is made, rather than a generic error. Then, detecting an illegal move could look something like this:
The text was updated successfully, but these errors were encountered: