using System;

namespace CommonHelpers {

//**************************************************************************************************
public static class HDBExceptionCreator {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/// <exception cref="ArgumentNullException" />
public static HOperationFailedException Create(string messageFmt,params object[] parameters)
{
   HArgChecking.VerifyNotNulls( messageFmt, parameters );
   return new HOperationFailedException( string.Format( messageFmt, parameters ) );
}
/// <exception cref="ArgumentNullException" />
public static HOperationFailedException Create(Exception error)
{
   HArgChecking.VerifyNotNull( error );
   return new HOperationFailedException( HException.GetErrorMessage( error ) );
}

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

/// <exception cref="ArgumentNullException" />
/// <exception cref="HOperationFailedException" />
public static void Do(Action action)
{
   HArgChecking.VerifyNotNull( action );
   try { action(); }
   catch (Exception e)
      { throw HDBExceptionCreator.Create( e ); }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // HDBExceptionCreator
//**************************************************************************************************

} // CommonHelpers
