public static IscException ForStrParam(string strParam, Exception innerException = null) { var result = new IscException(innerException); result.Errors.Add(new IscError(IscCodes.isc_arg_string, strParam)); result.BuildExceptionData(); return(result); }
public static IscException ForSQLSTATE(string sqlState, Exception innerException = null) { var result = new IscException(innerException); result.Errors.Add(new IscError(IscCodes.isc_arg_sql_state, sqlState)); result.BuildExceptionData(); return(result); }
public static IscException ForErrorCode(int errorCode, Exception innerException = null) { var result = new IscException(innerException); result.Errors.Add(new IscError(IscCodes.isc_arg_gds, errorCode)); result.BuildExceptionData(); return(result); }
public static IscException ForTypeErrorCodeIntParamStrParam(int type, int errorCode, int intParam, string strParam, Exception innerException = null) { var result = new IscException(innerException); result.Errors.Add(new IscError(type, errorCode)); result.Errors.Add(new IscError(IscCodes.isc_arg_number, intParam)); result.Errors.Add(new IscError(IscCodes.isc_arg_string, strParam)); result.BuildExceptionData(); return(result); }
public static IscException ForErrorCodes(IEnumerable <int> errorCodes, Exception innerException = null) { var result = new IscException(innerException); foreach (var errorCode in errorCodes) { result.Errors.Add(new IscError(IscCodes.isc_arg_gds, errorCode)); } result.BuildExceptionData(); return(result); }
public IscException ReadStatusVector() { IscException exception = null; bool eof = false; while (!eof) { int arg = ReadInt32(); switch (arg) { case IscCodes.isc_arg_gds: default: int er = ReadInt32(); if (er != 0) { if (exception == null) { exception = IscException.ForBuilding(); } exception.Errors.Add(new IscError(arg, er)); } break; case IscCodes.isc_arg_end: exception?.BuildExceptionData(); eof = true; break; case IscCodes.isc_arg_interpreted: case IscCodes.isc_arg_string: exception.Errors.Add(new IscError(arg, ReadString())); break; case IscCodes.isc_arg_number: exception.Errors.Add(new IscError(arg, ReadInt32())); break; case IscCodes.isc_arg_sql_state: exception.Errors.Add(new IscError(arg, ReadString())); break; } } return(exception); }
public async ValueTask <IscException> ReadStatusVectorAsync(CancellationToken cancellationToken = default) { IscException exception = null; var eof = false; while (!eof) { var arg = await ReadInt32Async(cancellationToken).ConfigureAwait(false); switch (arg) { case IscCodes.isc_arg_gds: default: var er = await ReadInt32Async(cancellationToken).ConfigureAwait(false); if (er != 0) { if (exception == null) { exception = IscException.ForBuilding(); } exception.Errors.Add(new IscError(arg, er)); } break; case IscCodes.isc_arg_end: exception?.BuildExceptionData(); eof = true; break; case IscCodes.isc_arg_interpreted: case IscCodes.isc_arg_string: case IscCodes.isc_arg_sql_state: exception.Errors.Add(new IscError(arg, await ReadStringAsync(cancellationToken).ConfigureAwait(false))); break; case IscCodes.isc_arg_number: exception.Errors.Add(new IscError(arg, await ReadInt32Async(cancellationToken).ConfigureAwait(false))); break; } } return(exception); }
public static IscException ParseStatusVector(IntPtr[] statusVector, Charset charset) { IscException exception = null; bool eof = false; for (int i = 0; i < statusVector.Length;) { IntPtr arg = statusVector[i++]; switch (arg.AsInt()) { case IscCodes.isc_arg_gds: default: IntPtr er = statusVector[i++]; if (er != IntPtr.Zero) { if (exception == null) { exception = IscException.ForBuilding(); } exception.Errors.Add(new IscError(arg.AsInt(), er.AsInt())); } break; case IscCodes.isc_arg_end: exception?.BuildExceptionData(); eof = true; break; case IscCodes.isc_arg_interpreted: case IscCodes.isc_arg_string: { IntPtr ptr = statusVector[i++]; string s = Marshal.PtrToStringAnsi(ptr); string arg_value = charset.GetString(Encoding2.Default.GetBytes(s)); exception.Errors.Add(new IscError(arg.AsInt(), arg_value)); } break; case IscCodes.isc_arg_cstring: { i++; IntPtr ptr = statusVector[i++]; string s = Marshal.PtrToStringAnsi(ptr); string arg_value = charset.GetString(Encoding2.Default.GetBytes(s)); exception.Errors.Add(new IscError(arg.AsInt(), arg_value)); } break; case IscCodes.isc_arg_win32: case IscCodes.isc_arg_number: exception.Errors.Add(new IscError(arg.AsInt(), statusVector[i++].AsInt())); break; case IscCodes.isc_arg_sql_state: { IntPtr ptr = statusVector[i++]; string s = Marshal.PtrToStringAnsi(ptr); string arg_value = charset.GetString(Encoding2.Default.GetBytes(s)); exception.Errors.Add(new IscError(arg.AsInt(), arg_value)); } break; } if (eof) { break; } } return(exception); }