catching an exception in an async Task [Answered]
I can't seem to catch an exception that is thrown in an async Task, I put try/catch within the async task, when calling the task I put 'ConfigureAwait(true)', and I await it, I also have a catch in the parent method
8 Replies
method exits when I try to create a refund in stripe
but nothing gets caught
You're not awaiting anything?
If you're not awaiting it, execution may occur asynchronously on a different thread after the current method returns, if any of those calls (e.g.: Get(...) or Create(...) ) are asynchronous calls that await other async methods perhaps.
Are those methods async Task methods?
this is the body of the awaited method
idk why it throws now, maybe a VS bug
What exception does it even throw?
Are you seeing it in the exception break?
Can you screenshot the call-stack of that exception?
Are you also absolutely sure that it's not caught internally by the methods?
no the method I call it from used to just exit, I rebuilt and now I can catch the exception, it's a StripeException, problem solved
just rebuilt it
thanks for the help
Okay, weird that.
Use command
/close
to close the post if you're happy to close it.oh nice to know
✅ This post has been marked as answered!