//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// UserRTX.NET satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;

#if !WASM
namespace user_rtx { using u = user_rtx;
#else
namespace user_rtx.wasm { using u = user_rtx.wasm;
#endif

static partial class com_error {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public static ESystemError ESystemError( int errorCode ) =>
   new ESystemError( HRToMessage( errorCode ) );

public static ESystemError ESystemError( int errorCode, [u.opt] IntPtr errorInfo ) =>
   new ESystemError( HRToMessage( errorCode, errorInfo ) );

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

public static ESystemError ESystemError( string functionName ) =>
   ESystemError( functionName, null );

public static ESystemError ESystemError( string functionName, string? remarkMessage ) =>
   new ESystemError( ErrorMessageFor( functionName, remarkMessage ) );

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

public static ESystemError ESystemErrorWithReturnCodeToken( string functionName,
                                                            string returnCodeToken ) =>
   new ESystemError(
      ErrorMessageWithReturnCodeToken( functionName, returnCodeToken ) );

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

public static ESystemError ESystemError_CantObtainInterface( string interfaceName, int hResult ) =>
   new ESystemError( u.SystemErrorKind.COM, unchecked( (UInt64)hResult ),
      ErrorMessage_CantObtainInterface( interfaceName, hResult ) );

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // com_error

} // user_rtx (.wasm)
