| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- //------------------------------------------------------------
- // Copyright (c) Microsoft Corporation. All rights reserved.
- //------------------------------------------------------------
- namespace System.ServiceModel.Administration
- {
- using System;
- using System.ComponentModel;
- using System.Diagnostics;
- internal class WbemException : Win32Exception
- {
- internal WbemException(WbemNative.WbemStatus hr)
- : base((int)hr)
- {
- }
- internal WbemException(int hr)
- : base(hr)
- {
- }
- internal WbemException(int hr, string message)
- : base(hr, message)
- {
- }
- internal static void Throw(WbemNative.WbemStatus hr)
- {
- switch (hr)
- {
- case WbemNative.WbemStatus.WBEM_E_NOT_FOUND:
- throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new WbemInstanceNotFoundException());
- case WbemNative.WbemStatus.WBEM_E_INVALID_PARAMETER:
- throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new WbemInvalidParameterException());
- case WbemNative.WbemStatus.WBEM_E_NOT_SUPPORTED:
- throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new WbemNotSupportedException());
- case WbemNative.WbemStatus.WBEM_E_INVALID_METHOD:
- throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new WbemInvalidMethodException());
- default:
- throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new WbemException(hr));
- }
- }
- internal static void ThrowIfFail(int hr)
- {
- if (hr < 0)
- {
- Throw((WbemNative.WbemStatus)hr);
- }
- }
- }
- internal class WbemInstanceNotFoundException : WbemException
- {
- internal WbemInstanceNotFoundException()
- : base(WbemNative.WbemStatus.WBEM_E_NOT_FOUND)
- {
- }
- }
- internal class WbemInvalidParameterException : WbemException
- {
- internal WbemInvalidParameterException(string name)
- : base((int)WbemNative.WbemStatus.WBEM_E_INVALID_PARAMETER, name)
- {
- }
- internal WbemInvalidParameterException()
- : base(WbemNative.WbemStatus.WBEM_E_INVALID_PARAMETER)
- {
- }
- }
- internal class WbemNotSupportedException : WbemException
- {
- internal WbemNotSupportedException()
- : base(WbemNative.WbemStatus.WBEM_E_NOT_SUPPORTED)
- {
- }
- }
- internal class WbemInvalidMethodException : WbemException
- {
- internal WbemInvalidMethodException()
- : base(WbemNative.WbemStatus.WBEM_E_INVALID_METHOD)
- {
- }
- }
- }
|