Created
August 30, 2019 13:06
-
-
Save bruceharrison1984/b99cc0ba94e909eec03318ea4fcef357 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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