Let's do a simple if and throw a RuntimeException when the result is not expected:
private void setBox(TicTacToeBean bean) { if (board[bean.getX() - 1][bean.getY() - 1] != ' ') { throw new RuntimeException("Box is occupied"); } else { board[bean.getX() - 1][bean.getY() - 1] = lastPlayer; // getTicTacToeCollection().saveMove(bean); if (!getTicTacToeCollection().saveMove(bean)) { throw new RuntimeException("Saving to DB failed"); } } }