private Microsoft.AspNetCore.Mvc.ObjectResult GenerateResultForException(Exception exception) { ErrorAnswer answer = _environment.IsDevelopment() ? new ErrorAnswer(exception, exception.InnerException) : new ErrorAnswer(); var res = new Microsoft.AspNetCore.Mvc.OkObjectResult(answer); return(res); }
private static AnswerModel HandleExceptionText(string text, HttpStatusCode code) { Debug.Log(text); var errors = new ErrorAnswer(); Dictionary <string, IList <string> > errorCodes = null; try { errors = JsonConvert.DeserializeObject <ErrorAnswer>(text); if (errors.ModelState != null && errors.ModelState.Any()) { errorCodes = errors.ModelState; } else { errorCodes = new Dictionary <string, IList <string> > { { "Message", new List <string> { errors.Message } } }; } } catch { errorCodes = new Dictionary <string, IList <string> > { { "Message", new List <string> { "FatalError" } } }; Canvaser.Errors.Enqueue(new WebException(text)); } return(new AnswerModel() { StatusCode = code, Errors = errorCodes }); }