System.Runtime.Serialization.XmlObjectSerializer.WriteObjectContentHandleExceptions C# (CSharp) Method

WriteObjectContentHandleExceptions() private method

private WriteObjectContentHandleExceptions ( System.Runtime.Serialization.XmlWriterDelegator writer, object graph ) : void
writer System.Runtime.Serialization.XmlWriterDelegator
graph object
return void
        internal void WriteObjectContentHandleExceptions(XmlWriterDelegator writer, object graph)
        {
            try
            {
                CheckNull(writer, nameof(writer));
                {
                    if (writer.WriteState != WriteState.Element)
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.XmlWriterMustBeInElement, writer.WriteState)));
                    InternalWriteObjectContent(writer, graph);
                }
            }
            catch (XmlException ex)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(GetTypeInfoError(SR.ErrorSerializing, GetSerializeType(graph), ex), ex));
            }
            catch (FormatException ex)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(GetTypeInfoError(SR.ErrorSerializing, GetSerializeType(graph), ex), ex));
            }
        }