/// <inheritdoc/> public override void WriteObject(object graph, Type type, ODataMessageWriter messageWriter, ODataSerializerContext writeContext) { if (graph == null) { throw Error.ArgumentNull("graph"); } if (messageWriter == null) { throw Error.ArgumentNull("messageWriter"); } ODataError oDataError = graph as ODataError; if (oDataError == null) { SerializableError httpError = graph as SerializableError; if (httpError == null) { string message = Error.Format(SRResources.ErrorTypeMustBeODataErrorOrHttpError, graph.GetType().FullName); throw new SerializationException(message); } else { oDataError = httpError.CreateODataError(); } } bool includeDebugInformation = oDataError.InnerError != null; messageWriter.WriteError(oDataError, includeDebugInformation); }
/// <summary> /// Create an ODataError from an HttpError. /// </summary> /// <param name="error">The error to use.</param> /// <returns>an ODataError.</returns> internal static ODataError CreateODataError(object error) { SerializableError serializableError = error as SerializableError; return(serializableError.CreateODataError()); }