this code in 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 expression valid."); } }
and in algebra.divide
put throwing exception testing exception scenario:
public static divisionresult divide (string expression) { throw new exception("error occured"); }
and here happens when click button:
why doesn't propagate exception action handler have try/catch block? tried without synchronous call algebra.divide()
same error.
simply said because debugger enabled. when run code without debugger catched in try catch block. should behaviour want when press f5 when see exception. put breakpoint on catch statement , see program continu running , go catch statement.
you can turn off break on exception. can described here: how turn off "break when exception thrown" custom exception types
Comments
Post a Comment