示例#1
0
        static internal OleDbException CreateException(UnsafeNativeMethods.IErrorInfo errorInfo, OleDbHResult errorCode, Exception inner)   // MDAC 84364
        {
            OleDbErrorCollection errors = new OleDbErrorCollection(errorInfo);
            string       message        = null;
            string       source         = null;
            OleDbHResult hr             = 0;

            if (null != errorInfo)
            {
                hr = errorInfo.GetDescription(out message);
                Bid.Trace("<oledb.IErrorInfo.GetDescription|API|OS|RET> %08X{HRESULT}, Description='%ls'\n", hr, message);

                hr = errorInfo.GetSource(out source);
                Bid.Trace("<oledb.IErrorInfo.GetSource|API|OS|RET> %08X{HRESULT}, Source='%ls'\n", hr, source);
            }

            int count = errors.Count;

            if (0 < errors.Count)
            {
                StringBuilder builder = new StringBuilder();

                if ((null != message) && (message != errors[0].Message))      // WebData 103032
                {
                    builder.Append(message.TrimEnd(ODB.ErrorTrimCharacters)); // MDAC 73707
                    if (1 < count)
                    {
                        builder.Append(Environment.NewLine);
                    }
                }
                for (int i = 0; i < count; ++i)
                {
                    if (0 < i)
                    {
                        builder.Append(Environment.NewLine);
                    }
                    builder.Append(errors[i].Message.TrimEnd(ODB.ErrorTrimCharacters)); // MDAC 73707
                }
                message = builder.ToString();
            }
            if (ADP.IsEmpty(message))
            {
                message = ODB.NoErrorMessage(errorCode); // MDAC 71170
            }
            return(new OleDbException(message, inner, source, errorCode, errors));
        }
示例#2
0
        static internal OleDbException CreateException(UnsafeNativeMethods.IErrorInfo errorInfo, OleDbHResult errorCode, Exception inner)
        {
            OleDbErrorCollection errors = new OleDbErrorCollection(errorInfo);
            string       message        = null;
            string       source         = null;
            OleDbHResult hr             = 0;

            if (null != errorInfo)
            {
                hr = errorInfo.GetDescription(out message);

                hr = errorInfo.GetSource(out source);
            }

            int count = errors.Count;

            if (0 < errors.Count)
            {
                StringBuilder builder = new StringBuilder();

                if ((null != message) && (message != errors[0].Message))
                {
                    builder.Append(message.TrimEnd(ODB.ErrorTrimCharacters));
                    if (1 < count)
                    {
                        builder.Append(Environment.NewLine);
                    }
                }
                for (int i = 0; i < count; ++i)
                {
                    if (0 < i)
                    {
                        builder.Append(Environment.NewLine);
                    }
                    builder.Append(errors[i].Message.TrimEnd(ODB.ErrorTrimCharacters));
                }
                message = builder.ToString();
            }
            if (ADP.IsEmpty(message))
            {
                message = ODB.NoErrorMessage(errorCode);
            }
            return(new OleDbException(message, inner, source, errorCode, errors));
        }
示例#3
0
        internal static OleDbException CreateException(System.Data.Common.UnsafeNativeMethods.IErrorInfo errorInfo, OleDbHResult errorCode, Exception inner)
        {
            OleDbErrorCollection errors   = new OleDbErrorCollection(errorInfo);
            string       pBstrDescription = null;
            string       pBstrSource      = null;
            OleDbHResult description      = OleDbHResult.S_OK;

            if (errorInfo != null)
            {
                description = errorInfo.GetDescription(out pBstrDescription);
                Bid.Trace("<oledb.IErrorInfo.GetDescription|API|OS|RET> %08X{HRESULT}, Description='%ls'\n", description, pBstrDescription);
                description = errorInfo.GetSource(out pBstrSource);
                Bid.Trace("<oledb.IErrorInfo.GetSource|API|OS|RET> %08X{HRESULT}, Source='%ls'\n", description, pBstrSource);
            }
            int count = errors.Count;

            if (0 < errors.Count)
            {
                StringBuilder builder = new StringBuilder();
                if ((pBstrDescription != null) && (pBstrDescription != errors[0].Message))
                {
                    builder.Append(pBstrDescription.TrimEnd(ODB.ErrorTrimCharacters));
                    if (1 < count)
                    {
                        builder.Append(Environment.NewLine);
                    }
                }
                for (int i = 0; i < count; i++)
                {
                    if (0 < i)
                    {
                        builder.Append(Environment.NewLine);
                    }
                    builder.Append(errors[i].Message.TrimEnd(ODB.ErrorTrimCharacters));
                }
                pBstrDescription = builder.ToString();
            }
            if (ADP.IsEmpty(pBstrDescription))
            {
                pBstrDescription = ODB.NoErrorMessage(errorCode);
            }
            return(new OleDbException(pBstrDescription, inner, pBstrSource, errorCode, errors));
        }
示例#4
0
        internal OleDbException(UnsafeNativeMethods.IErrorInfo errorInfo, int errorCode, Exception inner) : base("", inner)
        {
            // copy error information into this structure so that it can be serialized by value
            this.oledbErrors = new OleDbErrorCollection((UnsafeNativeMethods.IErrorRecords)errorInfo);

            if (null != errorInfo)
            {
                // message
#if DEBUG
                ODB.Trace_Begin(4, "IErrorInfo", "GetDescription");
#endif
                errorInfo.GetDescription(out this.message);
#if DEBUG
                ODB.Trace_End(4, "IErrorInfo", "GetDescription", 0, this.message);
#endif
                this.message = OleDbErrorCollection.BuildFullMessage(Errors, this.message);
                if (ADP.IsEmpty(this.message))
                {
                    this.message = ODB.NoErrorMessage(errorCode); // MDAC 71170
                }

                // source
#if DEBUG
                ODB.Trace_Begin(4, "IErrorInfo", "GetSource");
#endif
                errorInfo.GetSource(out this.source);
#if DEBUG
                ODB.Trace_End(4, "IErrorInfo", "GetSource", 0, this.source);
#endif
                if (null == this.source)
                {
                    this.source = "";
                }
            }
            HResult = errorCode;
        }