public JsonApiError(HttpError error, IErrorIdProvider idProvider) { Id = idProvider.GenerateId(error); Title = error.ExceptionType ?? error.Message; Status = "500"; Detail = error.ExceptionMessage ?? error.MessageDetail; StackTrace = error.StackTrace; if (error.InnerException != null) Inner = new JsonApiError(error.InnerException, idProvider); }
public JsonApiError(HttpError error, IErrorIdProvider idProvider) { Id = idProvider.GenerateId(error); Title = error.ExceptionType ?? error.Message; Status = "500"; Detail = error.ExceptionMessage ?? error.MessageDetail; StackTrace = error.StackTrace; if (error.InnerException != null) { Inner = new JsonApiError(error.InnerException, idProvider); } }
public void SerializeError(object error, Stream writeStream, JsonWriter writer, JsonSerializer serializer) { var httpError = error as HttpError; if (httpError == null) { throw new Exception("Unsupported error type."); } writer.WriteStartObject(); writer.WritePropertyName("errors"); var jsonApiError = new JsonApiError(httpError) { Id = _errorIdProvider.GenerateId(httpError) }; serializer.Serialize(writer, new[] { jsonApiError }); writer.WriteEndObject(); }