public static void FireError(int ErrorCode, int SubErrorCode, string ExtraInfo = "") { CodeLabException codelabExp = new CodeLabException { ErrorCode = ErrorCode, SubErrorCode = SubErrorCode, ErrorReferenceNumber = "UU-266169856" }; //codelabExp.Data.Add("LoggedInId", 88); //codelabExp.Data.Add("NoOfTrials", 3); codelabExp.ExtraInfoMessage = "call failed because " + ExtraInfo; throw codelabExp; }
public static ObjectResult GenerateErrorResponse(CodeLabException codelabExp) { List <CodeLabException> allErrors = new List <CodeLabException>(); allErrors.Add(codelabExp); ObjectResult res = new ObjectResult(allErrors); res.ContentTypes.Add("application/json"); var formatterSettings = JsonSerializerSettingsProvider.CreateSerializerSettings(); formatterSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; JsonOutputFormatter formatter = new JsonOutputFormatter(formatterSettings, ArrayPool <Char> .Create()); res.Formatters.Add(formatter); res.StatusCode = 490; return(res); }