Created
August 13, 2023 12:03
-
-
Save otienoelvis/33463a532edc258cedb0b0fd8af214d3 to your computer and use it in GitHub Desktop.
TestController.cs
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
using Microsoft.AspNetCore.Mvc; | |
namespace ErrorNotification.Controllers; | |
[Route("api/[controller]/[action]")] | |
[ApiController] | |
public class TestController : ControllerBase | |
{ | |
private readonly ILogger<TestController> _logger; | |
public TestController(ILogger<TestController> logger) | |
{ | |
_logger = logger; | |
} | |
[HttpGet] | |
public async Task<IActionResult> TestOkay() | |
{ | |
try | |
{ | |
_logger.LogInformation("Testing Okay"); | |
return Ok(); | |
} | |
catch (Exception e) | |
{ | |
_logger.LogError(e, e.Message); | |
throw; | |
} | |
} | |
[HttpGet] | |
public async Task<IActionResult> TestNotOkay() | |
{ | |
try | |
{ | |
throw new ArgumentNullException(nameof(TestNotOkay)); | |
} | |
catch (Exception e) | |
{ | |
_logger.LogError(e, e.Message); | |
throw; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment