Return specific error based on exception in ASP.NET Core?
Consider a controller endpoint like this: [HttpGet] public IActionResult Get() { var resource = _myService.GetSomeResource(); return Ok(resource); } The GetSomeResource() method performs validation on the identity of the caller, like this: public SomeResourceModel GetSomeResource() { _securityVerifier.VerifyCallerHasAccess(); // do stuff to…