//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// CommonHelpers satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#if WIN32
using System;
using System.ComponentModel;

#if !WASM
namespace CommonHelpers {
#else
namespace CommonHelpers.WASM {
#endif

//**************************************************************************************************
/// <summary>
/// </summary>
partial class HCOMError {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/// <exception cref="ArgumentNullException" />
public static HOperationFailedException CreateOpFailedException(int errorCode)
{
   return new HOperationFailedException( HRToMessage( errorCode ) );
}
/// <exception cref="ArgumentNullException" />
public static HOperationFailedException CreateOpFailedException( int errorCode,
                                                                 [HOptional] IntPtr errorInfo )
{
   return new HOperationFailedException( HRToMessage( errorCode, errorInfo ) );
}

//--------------------------------------------------------------------------------------------------

/// <exception cref="ArgumentNullException" />
public static HOperationFailedException CreateOpFailedException(string functionName)
{
   return CreateOpFailedException( functionName, null );
}
/// <exception cref="ArgumentNullException" />
public static HOperationFailedException CreateOpFailedException
(
   string functionName, [HOptional] string remarkMessage
)
{
   HArgChecking.VerifyNotNull( functionName );
   return HOpFailedExceptionCreator.Create(
      ComposeOpFailedErrorMessage( functionName, remarkMessage ) );
}

//==================================================================================================

/// <exception cref="ArgumentNullException" />
public static HOperationFailedException CreateOpFailedExceptionWithReturnCodeToken
(
   string functionName, string returnCodeToken
)
{
   HArgChecking.VerifyNotNulls( functionName, returnCodeToken );
   return CreateOpFailedException(
      ComposeOpFailedErrorMessageWithReturnCodeToken( functionName, returnCodeToken ) );
}

//==================================================================================================

/// <exception cref="ArgumentNullException" />
public static HOperationFailedException CreateOpFailedException_CantObtainInterface
(
   string interfaceName, int hResult
)
{
   HArgChecking.VerifyNotNull( interfaceName );
   return HOpFailedExceptionCreator.Create(
      "Can not obtain COM-interface \"{0}\".\n"+
      "{1}.", interfaceName, HRToMessage( hResult ) );
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // HCOMError
//**************************************************************************************************

} // CommonHelpers (.WASM)
#endif // WIN32
