internal async Task WriteErrorResponseAsync(HttpContext httpContext, ODataException oe) { var error = new Error { Code = string.IsNullOrEmpty(oe.ErrorCode) ? Enum.GetName(typeof(ODataExceptionCode), oe.ODataExceptionCode) : oe.ErrorCode, ExceptionType = oe.InnerException?.GetType().Name ?? oe.GetType().Name, Message = new ErrorMessage { Lang = System.Globalization.CultureInfo.CurrentUICulture.Name.ToLower(), Value = SNSR.GetString(oe.Message).Replace(Environment.NewLine, "\\n").Replace('"', ' ').Replace('\'', ' ').Replace(" \\ ", " ") }, InnerError = #if DEBUG new StackInfo { Trace = Utility.CollectExceptionMessages(oe) } #else null #endif }; httpContext.Response.ContentType = "application/json"; httpContext.Response.StatusCode = oe.HttpStatusCode; await WriteErrorAsync(httpContext, error).ConfigureAwait(false); }