/// <summary> /// Writes an <see cref="ODataError"/> into the message payload. /// </summary> /// <param name="error">The error to write.</param> /// <param name="includeDebugInformation"> /// A flag indicating whether debug information (e.g., the inner error from the <paramref name="error"/>) should /// be included in the payload. This should only be used in debug scenarios. /// </param> /// <remarks> /// This method is called if the ODataMessageWriter.WriteError is called once some other /// write operation has already started. /// The method should write the in-stream error representation for the specific format into the current payload. /// Before the method is called no flush is performed on the output context or any active writer. /// It is the responsibility of this method to flush the output before the method returns. /// </remarks> internal override void WriteInStreamError(ODataError error, bool includeDebugInformation) { this.AssertSynchronous(); ODataMetadataWriterUtils.WriteError(this.xmlWriter, error, includeDebugInformation, this.MessageWriterSettings.MessageQuotas.MaxNestingDepth); this.Flush(); }
/// <summary> /// Writes an <see cref="ODataError"/> into the message payload. /// </summary> /// <param name="error">The error to write.</param> /// <param name="includeDebugInformation"> /// A flag indicating whether debug information (e.g., the inner error from the <paramref name="error"/>) should /// be included in the payload. This should only be used in debug scenarios. /// </param> /// <returns>Task which represents the pending write operation.</returns> internal override Task WriteInStreamErrorAsync(ODataError error, bool includeDebugInformation) { this.AssertAsynchronous(); return(TaskUtils.GetTaskForSynchronousOperationReturningTask( () => { ODataMetadataWriterUtils.WriteError(this.xmlWriter, error, includeDebugInformation, this.MessageWriterSettings.MessageQuotas.MaxNestingDepth); return this.FlushAsync(); })); }