Hi @Jesse,
Using below custom code, I am able to send exception as a response to logic apps:
namespace trestnamespce
{
using System;
using System.Threading.Tasks;
using Microsoft.Azure.Functions.Extensions.Workflows;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
public class testing
{
private readonly ILogger<testing> rilg;
public testing(ILoggerFactory loggerFactory)
{
rilg = loggerFactory.CreateLogger<testing>();
}
[FunctionName("testing")]
public Task<object> Run([WorkflowActionTrigger] string Name)
{
try
{
rilg.LogInformation($"Hello Rithwik");
throw new InvalidOperationException($"Hello Rithwik, The Test Exception.{Name}");
}
catch (Exception ex)
{
rilg.LogError(ex, "[testing] Exception occurred");
return Task.FromResult<object>(new
{
success = false,
errorMessage = ex.Message,
errorType = ex.GetType().Name
});
}
}
}
}
After using the above code, build the code again.
Design after Deploying to Azure:
Output:
If this answer was helpful, please click "Accept the answer" and mark Yes
, as this can help other community members.
If you have any other questions or are still experiencing issues, feel free to ask in the "comments" section, and I'd be happy to help.