public static void ThrowError(ApplicationErrors error, params object[] data) { #if DEBUG SmartCalculatorException ex = GetException(error, data); if (ex.Message.StartsWith("Unknown error, ")) { LogException(ex); } throw ex; #else ShowError(null, Texts.GetString(error.ToString()), Constants.ReadMeFileName); #endif }
public static SmartCalculatorException GetException(ApplicationErrors error, params object[] data) { return(error switch { ApplicationErrors.ConversionError => new ConversionException(Program.MainForm.CurrentModeComboBox.SelectedItem.ToString()), ApplicationErrors.CalculatingError => new CalculatingException(Texts.GetString(error.ToString())) { HelpLink = Constants.ReadMeFileName }, ApplicationErrors.OperationError => new SmartCalculatorException(Program.MainForm), ApplicationErrors.ReadingFileError => new ReadingFileException("ReadingFileError", data[0].ToString()), ApplicationErrors.UnknownError => new SmartCalculatorException("Unknown error, Send to [email protected]") { Window = Form.ActiveForm }, _ => throw new ArgumentException("Not supported error!", nameof(error)), });
private async void LoginButton_Clicked(object sender, EventArgs e) { LoginButton.Text = "LOGGING IN..."; LoginButton.IsEnabled = false; CloudOperationResult opResult = await Users.Login(EmailEntry.Text, PasswordEntry.Text); if (opResult.Success == false) { await DisplayAlert("Error", ApplicationErrors.GetError(opResult.Error).Message, "OK"); LoginButton.Text = "LOG IN"; LoginButton.IsEnabled = true; return; } LoginButton.Text = "LOG IN"; LoginButton.IsEnabled = true; Navigation.InsertPageBefore(new HomePage(), this); await Navigation.PopAsync(); }
private async void RegisterButton_Clicked(object sender, EventArgs e) { if (PasswordEntry.Text == PasswordConfirmEntry.Text) { var result = await Users.RegisterUser(user); if (result.Success == false) { switch (result.Error) { case ErrorCode.UserExists: await DisplayAlert("Error", ApplicationErrors.GetError(result.Error).Message, "OK"); return; } } await DisplayAlert("Success", "You have successfully registered!", "OK"); } else { await DisplayAlert("Error", ApplicationErrors.GetError(ErrorCode.PasswordMismatch).Message, "OK"); } }
public static string Format(this ApplicationErrors error, string parameter) { return(String.Format(ErrorMessages.Error(ApplicationErrors.CREATE_ERROR), parameter)); }
protected void ShowError(ApplicationErrors error) { ResultLabel.Text = Texts.GetString(error.ToString()); ResultLabel.BackColor = Color.Red; CurrentError = error; }
public static string Error(ApplicationErrors error) { return(_errors.ContainsKey(error) ? _errors[error] : _errors[ApplicationErrors.UNKNOWN_ERROR]); }