internal static OracleException CreateException(OciErrorHandle errorHandle, int rc) { using (NativeBuffer buffer = new NativeBuffer_Exception(0x3e8)) { int num; string str; if (errorHandle != null) { int recordno = 1; int num2 = TracedNativeMethods.OCIErrorGet(errorHandle, recordno, out num, buffer); if (num2 == 0) { str = errorHandle.PtrToString(buffer); if (((num != 0) && str.StartsWith("ORA-00000", StringComparison.Ordinal)) && (TracedNativeMethods.oermsg((short)num, buffer) == 0)) { str = errorHandle.PtrToString(buffer); } } else { str = Res.GetString("ADP_NoMessageAvailable", new object[] { rc, num2 }); num = 0; } if (ConnectionIsBroken(num)) { errorHandle.ConnectionIsBroken = true; } } else { str = Res.GetString("ADP_NoMessageAvailable", new object[] { rc, -1 }); num = 0; } return(new OracleException(str, num)); } }
internal OracleException( OciHandle errorHandle, int rc, NativeBuffer buf) { if (null == buf) { buf = new NativeBuffer_Exception(1000); } else if (buf.Length < 1000) { buf.Length = 1000; } if (null != errorHandle) { int record = 1; int rcTemp = TracedNativeMethods.OCIErrorGet( errorHandle, record, ADP.NullHandleRef, out code, buf.Ptr, buf.Length ); if (0 == rcTemp) { message = errorHandle.PtrToString((IntPtr)buf.Ptr); // For warning messages, revert back to the OCI7 routine to get // the text of the message. if (code != 0 && message.StartsWith("ORA-00000")) { message = TracedNativeMethods.oermsg(errorHandle, (short)code, buf); } } else { Debug.Assert(false, "Failed to get oracle message text"); // If we couldn't successfully read the message text, we pick // something more descriptive, like "we couldn't read the message" // instead of just handing back an empty string... message = Res.GetString(Res.ADP_NoMessageAvailable, rc, rcTemp); code = 0; } } #if USEORAMTS else { int length = buf.Length; code = 0; int rcTemp = TracedNativeMethods.OraMTSOCIErrGet(ref code, buf.Ptr, ref length); if (1 == rcTemp) { message = Marshal.PtrToStringAnsi((IntPtr)buf.Ptr); } else { Debug.Assert(false, "Failed to get oracle message text"); // If we couldn't successfully read the message text, we pick // something more descriptive, like "we couldn't read the message" // instead of just handing back an empty string... message = Res.GetString(Res.ADP_NoMessageAvailable, rc, rcTemp); code = 0; } } #endif //USEORAMTS }