public JsonResult GetExampleModel() { try { _logger.LogInformation("Get example model"); var exampleModel = _service.GetExampleModel(); return(Json(exampleModel)); } catch (Exception ex) { _logger.LogError(ex.Message); // This is just one way to do this. There is plenty of other ways to return // status description and status. One would be to return IActionResult instead of // JsonResult and give BadRequest. return(Json(new JsonStatusResponseModel { Description = "Error happened in get request", StatusCode = 400 })); } }