private OleDbException(string message, Exception inner, string source, OleDbHResult errorCode, OleDbErrorCollection errors) : base(message, inner) { Debug.Assert(null != errors, "OleDbException without OleDbErrorCollection"); Source = source; HResult = (int)errorCode; this.oledbErrors = errors; }
static internal String BuildFullMessage(OleDbErrorCollection errors, string errMsg) // MDAC 65533 { if ((null != errors) && (0 < errors.Count)) { StringBuilder str = new StringBuilder(); int count = errors.Count; if ((null != errMsg) && (0 != ADP.DstCompare(errMsg, errors[0].Message))) { str.Append(errMsg.TrimEnd(ODB.ErrorTrimCharacters)); // MDAC 73707 if (1 < count) { str.Append("\r\n"); } } for (int i = 0; i < count; ++i) { if (0 < i) { str.Append("\r\n"); } str.Append(errors[i].Message.TrimEnd(ODB.ErrorTrimCharacters)); // MDAC 73707 } return(str.ToString()); } return(""); }
internal static OleDbException CombineExceptions(List<OleDbException> exceptions) { if (1 >= exceptions.Count) { return exceptions[0]; } OleDbErrorCollection errors = new OleDbErrorCollection(null); StringBuilder builder = new StringBuilder(); foreach (OleDbException exception in exceptions) { errors.AddRange(exception.Errors); builder.Append(exception.Message); builder.Append(Environment.NewLine); } return new OleDbException(builder.ToString(), null, exceptions[0].Source, (OleDbHResult) exceptions[0].ErrorCode, errors); }
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)); }
internal static OleDbException CombineExceptions(List <OleDbException> exceptions) { if (1 >= exceptions.Count) { return(exceptions[0]); } OleDbErrorCollection errors = new OleDbErrorCollection(null); StringBuilder builder = new StringBuilder(); foreach (OleDbException exception in exceptions) { errors.AddRange(exception.Errors); builder.Append(exception.Message); builder.Append(Environment.NewLine); } return(new OleDbException(builder.ToString(), null, exceptions[0].Source, (OleDbHResult)exceptions[0].ErrorCode, errors)); }
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)); }
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)); }
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); }
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); }
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; }
internal OleDbException(string message, int errorCode, Exception inner) : base(message, inner) { this.oledbErrors = new OleDbErrorCollection(null); this.message = message; HResult = errorCode; }
internal OleDbInfoMessageEventArgs(OleDbErrorCollection errors) { this.errors = errors; }
private OleDbException(SerializationInfo si, StreamingContext sc) : base(si, sc) { this.oledbErrors = (OleDbErrorCollection)si.GetValue("oledbErrors", typeof(OleDbErrorCollection)); }
protected internal sealed override void OnSqlWarning(SQLWarning warning) { OleDbErrorCollection col = new OleDbErrorCollection(warning, this); OnOleDbInfoMessage(new OleDbInfoMessageEventArgs(col)); }
internal OleDbException(string message, OleDbHResult errorCode, Exception inner) : base(message, inner) { HResult = (int)errorCode; this.oledbErrors = new OleDbErrorCollection(null); }
internal bool ShouldSerializeErrors() // MDAC 65548 { OleDbErrorCollection errors = this.oledbErrors; return((null != errors) && (0 < errors.Count)); }
internal OleDbException(OleDbException previous, Exception inner) : base(previous.Message, inner) { base.HResult = previous.ErrorCode; this.oledbErrors = previous.oledbErrors; }
protected internal sealed override void OnSqlWarning(SQLWarning warning) { OleDbErrorCollection col = new OleDbErrorCollection(warning, this); OnOleDbInfoMessage(new OleDbInfoMessageEventArgs(col)); }
private OleDbException(string message, Exception inner, string source, OleDbHResult errorCode, OleDbErrorCollection errors) : base(message, inner) { // MDAC 84364 Debug.Assert(null != errors, "OleDbException without OleDbErrorCollection"); Source = source; HResult = (int)errorCode; this.oledbErrors = errors; }
static internal OleDbException CombineExceptions(List<OleDbException> exceptions) { Debug.Assert(0 < exceptions.Count, "missing exceptions"); if (1 < exceptions.Count) { OleDbErrorCollection errors = new OleDbErrorCollection(null); StringBuilder builder = new StringBuilder(); foreach(OleDbException exception in exceptions) { errors.AddRange(exception.Errors); builder.Append(exception.Message); builder.Append(Environment.NewLine); } return new OleDbException(builder.ToString(), null, exceptions[0].Source, (OleDbHResult)exceptions[0].ErrorCode, errors); } else { return exceptions[0]; } }
// runtime will call even if private... // <fxcop ignore=SerializableTypesMustHaveMagicConstructorWithAdequateSecurity /> private OleDbException(SerializationInfo si, StreamingContext sc) : base(si, sc) { oledbErrors = (OleDbErrorCollection)si.GetValue("oledbErrors", typeof(OleDbErrorCollection)); message = (string)si.GetValue("message", typeof(string)); source = (string)si.GetValue("source", typeof(string)); }
internal OleDbException(string message, OleDbHResult errorCode, Exception inner) : base(message, inner) { base.HResult = (int) errorCode; this.oledbErrors = new OleDbErrorCollection(null); }
internal OleDbInfoMessageEventArgs(OleDbErrorCollection errors) { this.errors = errors; }
private OleDbException(string message, Exception inner, string source, OleDbHResult errorCode, OleDbErrorCollection errors) : base(message, inner) { this.Source = source; base.HResult = (int) errorCode; this.oledbErrors = errors; }
internal OleDbException(OleDbException previous, Exception inner) : base(previous.Message, inner) { HResult = previous.ErrorCode; this.oledbErrors = previous.oledbErrors; }
internal bool ShouldSerializeErrors() { OleDbErrorCollection oledbErrors = this.oledbErrors; return((oledbErrors != null) && (0 < oledbErrors.Count)); }
private OleDbException(SerializationInfo si, StreamingContext sc) : base(si, sc) { this.oledbErrors = (OleDbErrorCollection) si.GetValue("oledbErrors", typeof(OleDbErrorCollection)); }
private OleDbException(string message, Exception inner, string source, OleDbHResult errorCode, OleDbErrorCollection errors) : base(message, inner) { this.Source = source; base.HResult = (int)errorCode; this.oledbErrors = errors; }