Quantcast
Viewing latest article 12
Browse Latest Browse All 13

Answer by Chris Halcrow for ASP.NET Core Web API exception handling

A simple way to handle an exception on any particular method is:

using Microsoft.AspNetCore.Http;...public ActionResult MyAPIMethod(){    try    {       var myObject = ... something;       return Json(myObject);    }    catch (Exception ex)    {        Log.Error($"Error: {ex.Message}");        return StatusCode(StatusCodes.Status500InternalServerError);    }         }

Viewing latest article 12
Browse Latest Browse All 13

Trending Articles