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 }
protected void ShowError(ApplicationErrors error) { ResultLabel.Text = Texts.GetString(error.ToString()); ResultLabel.BackColor = Color.Red; CurrentError = error; }
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)), });