Is there a way to call an async
method within a catch block?
At the moment I have an application which logs exceptions with an async
/ await
ed method but I can't put this in a catch block because I'm told:
The 'await' operator cannot occur inside a catch or finally block of a try-statement, inside the block of a lock-statment or in an unsafe context.
At the moment I'm having to assign the exception to a variable inside the catch block and then call my await logException()
afterwards.
Whilst this isn't the end of the world, it seems like there should / could be another / better way.
Any thoughts?