Added try-catch to is_move_legal()