This is code in my action handler:
private async void startButton_Click(object sender, EventArgs e)
{
try
{
var expression = expressionTextBox.Text;
var result = await Task.Run(() => Algebra.Divide(expression));
resultTextBox.Text = result.Polynom.ToString();
} catch (Exception ex)
{
Logger.Error(ex.Message);
detailsTextbox.BackColor = Color.Red;
detailsTextbox.AppendText("An error occurred! Please check if your expression is valid.");
}
}
And in Algebra.Divide
I only put throwing exception for testing exception scenario:
public static DivisionResult Divide (string expression)
{
throw new Exception("Error occured");
}
And here is what happens when I click button:
Why doesn't it propagate exception to action handler where I have try/catch block? I tried also without synchronous call to Algebra.Divide()
but it is the same error.