public HttpListenerException(int errorCode, string message) : base(errorCode, message) { if (NetEventSource.IsEnabled) { NetEventSource.Info(this, NativeErrorCode.ToString() + ":" + Message); } }
/// <devdoc> /// <para> /// Creates a new instance of the <see cref='System.Net.Sockets.SocketException'/> class with the specified error code. /// </para> /// </devdoc> public SocketException(int errorCode) : base(errorCode) { if (GlobalLog.IsEnabled) { GlobalLog.Print("SocketException::.ctor(int) " + NativeErrorCode.ToString() + ":" + Message); } }
public HttpListenerException() : base(Marshal.GetLastWin32Error()) { if (NetEventSource.IsEnabled) { NetEventSource.Info(this, NativeErrorCode.ToString() + ":" + Message); } }
static void ExceptionHandler(Exception ex) { // This is an example of accessing VISA.NET exceptions if (ex is IOTimeoutException) { Console.WriteLine("A timeout has occurred!\r\n"); } else if (ex is NativeVisaException) { Console.WriteLine("A native VISA exception has occurred!\r\n"); // To get more information about the error look at the ErrorCode property by // typecasting the generic exception to the more-specific Native VISA Exception int errorCode = (ex as NativeVisaException).ErrorCode; Console.WriteLine("\r\n\tError code: {0}\r\n\tError name: {1}\r\n", errorCode, NativeErrorCode.GetMacroNameFromStatusCode(errorCode)); } else if (ex is VisaException) { Console.WriteLine("A VISA exception has occurred!\r\n"); } else { Console.WriteLine("Some other type of exception occurred: {0}\r\n", ex.GetType()); } }
/// <devdoc> /// <para> /// Creates a new instance of the <see cref='System.Net.Sockets.SocketException'/> class with the default error code. /// </para> /// </devdoc> public SocketException() : base(Marshal.GetLastWin32Error()) { if (GlobalLog.IsEnabled) { GlobalLog.Print("SocketException::.ctor() " + NativeErrorCode.ToString() + ":" + Message); } }
public static ErrorCode ConvertToManaged(this NativeErrorCode errorCode) { switch (errorCode) { case NativeErrorCode.Unknown: case NativeErrorCode.Cancelled: case NativeErrorCode.Success: return(ErrorCode.Unknown); case NativeErrorCode.NotFound: return(ErrorCode.NotFound); case NativeErrorCode.Forbidden: return(ErrorCode.Forbidden); case NativeErrorCode.InvalidParameter: return(ErrorCode.InvalidParameter); case NativeErrorCode.Conflict: return(ErrorCode.Conflict); case NativeErrorCode.AggregateError: return(ErrorCode.AggregateError); } throw new NotSupportedException(string.Format("Unknown native error code {0}", errorCode)); }
protected SocketException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { if (GlobalLog.IsEnabled) { GlobalLog.Print("SocketException::.ctor(serialized) " + NativeErrorCode.ToString() + ":" + Message); } }
protected HttpListenerException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { if (NetEventSource.IsEnabled) { NetEventSource.Info(this, NativeErrorCode.ToString() + ":" + Message); } }
internal CimException(MI_Result errorCode, string errorMessage, MI_Instance errorDetailsHandle, string exceptionMessage) : base(exceptionMessage ?? CimException.GetExceptionMessage(errorCode, errorMessage, errorDetailsHandle)) { this.NativeErrorCode = errorCode.ToNativeErrorCode(); if (errorDetailsHandle != null) { this._errorData = new CimInstance(errorDetailsHandle.Clone()); } }
/// <summary> /// Convert <see cref="NativeErrorCode"/> to <see cref="ErrorCategory"/>. /// </summary> /// <param name="nativeErrorCode"></param> /// <returns></returns> internal static ErrorCategory ConvertCimNativeErrorCodeToErrorCategory(NativeErrorCode nativeErrorCode) { switch (nativeErrorCode) { case NativeErrorCode.Failed: return(ErrorCategory.NotSpecified); case NativeErrorCode.AccessDenied: return(ErrorCategory.PermissionDenied); case NativeErrorCode.InvalidNamespace: return(ErrorCategory.MetadataError); case NativeErrorCode.InvalidParameter: return(ErrorCategory.InvalidArgument); case NativeErrorCode.InvalidClass: return(ErrorCategory.MetadataError); case NativeErrorCode.NotFound: return(ErrorCategory.ObjectNotFound); case NativeErrorCode.NotSupported: return(ErrorCategory.NotImplemented); case NativeErrorCode.ClassHasChildren: return(ErrorCategory.MetadataError); case NativeErrorCode.ClassHasInstances: return(ErrorCategory.MetadataError); case NativeErrorCode.InvalidSuperClass: return(ErrorCategory.MetadataError); case NativeErrorCode.AlreadyExists: return(ErrorCategory.ResourceExists); case NativeErrorCode.NoSuchProperty: return(ErrorCategory.MetadataError); case NativeErrorCode.TypeMismatch: return(ErrorCategory.InvalidType); case NativeErrorCode.QueryLanguageNotSupported: return(ErrorCategory.NotImplemented); case NativeErrorCode.InvalidQuery: return(ErrorCategory.InvalidArgument); case NativeErrorCode.MethodNotAvailable: return(ErrorCategory.MetadataError); case NativeErrorCode.MethodNotFound: return(ErrorCategory.MetadataError); case NativeErrorCode.NamespaceNotEmpty: return(ErrorCategory.MetadataError); case NativeErrorCode.InvalidEnumerationContext: return(ErrorCategory.MetadataError); case NativeErrorCode.InvalidOperationTimeout: return(ErrorCategory.InvalidArgument); case NativeErrorCode.PullHasBeenAbandoned: return(ErrorCategory.OperationStopped); case NativeErrorCode.PullCannotBeAbandoned: return(ErrorCategory.CloseError); case NativeErrorCode.FilteredEnumerationNotSupported: return(ErrorCategory.NotImplemented); case NativeErrorCode.ContinuationOnErrorNotSupported: return(ErrorCategory.NotImplemented); case NativeErrorCode.ServerLimitsExceeded: return(ErrorCategory.ResourceBusy); case NativeErrorCode.ServerIsShuttingDown: return(ErrorCategory.ResourceUnavailable); default: return(ErrorCategory.NotSpecified); } }
/// <summary> /// Convert <see cref="NativeErrorCode"/> to <see cref="ErrorCategory"/>. /// </summary> /// <param name="nativeErrorCode"></param> /// <returns></returns> internal static ErrorCategory ConvertCimNativeErrorCodeToErrorCategory(NativeErrorCode nativeErrorCode) { switch (nativeErrorCode) { case NativeErrorCode.Failed: return ErrorCategory.NotSpecified; case NativeErrorCode.AccessDenied: return ErrorCategory.PermissionDenied; case NativeErrorCode.InvalidNamespace: return ErrorCategory.MetadataError; case NativeErrorCode.InvalidParameter: return ErrorCategory.InvalidArgument; case NativeErrorCode.InvalidClass: return ErrorCategory.MetadataError; case NativeErrorCode.NotFound: return ErrorCategory.ObjectNotFound; case NativeErrorCode.NotSupported: return ErrorCategory.NotImplemented; case NativeErrorCode.ClassHasChildren: return ErrorCategory.MetadataError; case NativeErrorCode.ClassHasInstances: return ErrorCategory.MetadataError; case NativeErrorCode.InvalidSuperClass: return ErrorCategory.MetadataError; case NativeErrorCode.AlreadyExists: return ErrorCategory.ResourceExists; case NativeErrorCode.NoSuchProperty: return ErrorCategory.MetadataError; case NativeErrorCode.TypeMismatch: return ErrorCategory.InvalidType; case NativeErrorCode.QueryLanguageNotSupported: return ErrorCategory.NotImplemented; case NativeErrorCode.InvalidQuery: return ErrorCategory.InvalidArgument; case NativeErrorCode.MethodNotAvailable: return ErrorCategory.MetadataError; case NativeErrorCode.MethodNotFound: return ErrorCategory.MetadataError; case NativeErrorCode.NamespaceNotEmpty: return ErrorCategory.MetadataError; case NativeErrorCode.InvalidEnumerationContext: return ErrorCategory.MetadataError; case NativeErrorCode.InvalidOperationTimeout: return ErrorCategory.InvalidArgument; case NativeErrorCode.PullHasBeenAbandoned: return ErrorCategory.OperationStopped; case NativeErrorCode.PullCannotBeAbandoned: return ErrorCategory.CloseError; case NativeErrorCode.FilteredEnumerationNotSupported: return ErrorCategory.NotImplemented; case NativeErrorCode.ContinuationOnErrorNotSupported: return ErrorCategory.NotImplemented; case NativeErrorCode.ServerLimitsExceeded: return ErrorCategory.ResourceBusy; case NativeErrorCode.ServerIsShuttingDown: return ErrorCategory.ResourceUnavailable; default: return ErrorCategory.NotSpecified; } }
protected HttpListenerException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext) { GlobalLog.Print("HttpListenerException::.ctor(serialized) " + NativeErrorCode.ToString() + ":" + Message); }
public HttpListenerException(int errorCode, string message) : base(errorCode, message) { GlobalLog.Print("HttpListenerException::.ctor(int) " + NativeErrorCode.ToString() + ":" + Message); }
public HttpListenerException() : base(Marshal.GetLastWin32Error()) { GlobalLog.Print("HttpListenerException::.ctor() " + NativeErrorCode.ToString() + ":" + Message); }
internal Error(NativeErrorCode errorCode, string message) { m_ErrorCode = errorCode; m_Message = message; }
private NativeErrorException(NativeErrorCode nativeErrorCode) : base($"Error code: {nativeErrorCode}") { NativeErrorCode = nativeErrorCode; }