Skip to content

Instantly share code, notes, and snippets.

@bruceharrison1984
Created August 30, 2019 13:06
Show Gist options
  • Save bruceharrison1984/b99cc0ba94e909eec03318ea4fcef357 to your computer and use it in GitHub Desktop.
Save bruceharrison1984/b99cc0ba94e909eec03318ea4fcef357 to your computer and use it in GitHub Desktop.
public class FunctionWrapper
{
private readonly ILogger _log;
public FunctionWrapper(ILogger<FunctionWrapper> log)
{
_log = log;
}
public async Task<IActionResult> Execute(Func<Task<IActionResult>> azureFunction)
{
try
{
return await azureFunction();
}
catch (Exception e)
{
_log.LogError(e, "Unhandled exception occured in FunctionWrapper");
return new CustomObjectResult(e.Message, StatusCodes.Status500InternalServerError);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment