When an exception is thrown in an Activity which has a message containing multiple lines which is then thrown as a TaskFailedException in an orchestration, only the first line of the message is available in FailureDetails.ErrorMessage
Expected behavior
All lines of the exception message are retained in TaskFailedException.FailureDetails.ErrorMessage
Actual behavior
Only the first line of the message is available in TaskFailedException.FailureDetails.ErrorMessage
Relevant source code snippets
[Function(nameof(OrchRun))]
public async Task OrchRun([OrchestrationTrigger] TaskOrchestrationContext context)
{
try
{
await context.CallActivityAsync(nameof(ActivityRun));
}
catch (TaskFailedException ex)
{
Console.WriteLine(ex.FailureDetails.ErrorMessage);
}
}
[Function(nameof(ActivityRun))]
public void ActivityRun([ActivityTrigger] TaskActivityContext context)
{
throw new InvalidOperationException($"Now you see me{Environment.NewLine}Now you dont");
}
Known workarounds
Enabling user code exceptions in the worker seems to include the extra lines in the message, however, the side effect of this is that the FailureDetails.ErrorType of the exception is (unknown) similar to #2697.
var host = new HostBuilder()
.ConfigureFunctionsWebApplication()
.ConfigureServices(services =>
{
services.Configure<WorkerOptions>(configure =>
{
configure.EnableUserCodeException = true;
});
}).Build()
Description
When an exception is thrown in an Activity which has a message containing multiple lines which is then thrown as a
TaskFailedException
in an orchestration, only the first line of the message is available inFailureDetails.ErrorMessage
Expected behavior
All lines of the exception message are retained in
TaskFailedException.FailureDetails.ErrorMessage
Actual behavior
Only the first line of the message is available in
TaskFailedException.FailureDetails.ErrorMessage
Relevant source code snippets
Known workarounds
Enabling user code exceptions in the worker seems to include the extra lines in the message, however, the side effect of this is that the
FailureDetails.ErrorType
of the exception is (unknown) similar to #2697.App Details