azure-webjobs-sdk-extensions
azure-webjobs-sdk-extensions copied to clipboard
Pattern matching not working for TraceEvent.Exception when using ErrorTrigger
I'm not sure if this is a bug or a misunderstanding from my side but I'm trying to use pattern matching for logging different exceptions in different ways. Nothing fancy. However, all exceptions is logged via the last else
-statement.
Repro steps
Stripped down version of my webjob for handling unhandled exceptions:
public void UnhandledException([ErrorTrigger("0:01:00", 1)] TraceFilter filter, TextWriter log)
{
foreach (var traceEvent in filter.GetEvents())
{
var exception = traceEvent.Exception;
if (exception is ClientExceptionBase clientException) // Custom exception, abstract base class
{
_logger.Error(clientException, clientException.ErrorMessages);
}
else if (exception is HttpResponseException httpResponseException)
{
_logger.Error(httpResponseException, "Response code here");
}
else if (exception is InternalServerErrorException internalServerErrorException) // Custom exception
{
_logger.Error(internalServerErrorException, "That's bad");
}
else
{
_logger.Error(exception); // <-- This is the only one logging the exceptions
}
}
}
Expected behavior
Pattern matching should work with TraceEvent.Exception
.
Actual behavior
Pattern matching does not work with TraceEvent.Exception
.
Known workarounds
Nope
Related information
Package version: 2.2.0