private void btnPlay_Click(object sender, EventArgs e) { try { if (EmptyNicknameException(txtNickname.Text)) { //Verifys that text added in the textbox is not empty throw new EmptyNicknameException("Text can't be empty"); } if (MaxCharactersException(txtNickname.Text)) { //Verifys that text added in the textbox is not more than 15 characters throw new MaxCharactersException("Text can't have more than 15 characters"); } if (WrongCharactersException(txtNickname.Text)) { //Verifys that text added in the textbox is not a symbol throw new WrongCharactersException("Text can only have alphanumeric and numeric characters"); } string aux = txtNickname.Text; try { foreach (var player in ControllerPlayer.NicknameList()) { if (player.nickname.Equals(aux)) { StaticAttributes.nicknameRepeated = true; } } } catch (Exception) { MessageBox.Show("error"); } Game game = new Game(aux); game.Show(); Hide(); } catch (EmptyNicknameException exc) { MessageBox.Show(exc.Message); } catch (MaxCharactersException exc) { MessageBox.Show(exc.Message); } catch (WrongCharactersException exc) { MessageBox.Show(exc.Message); } catch (Exception) { MessageBox.Show("An error has occurred"); } }