using System;

using CommonHelpers;

namespace SqlToCsvExport {

//**************************************************************************************************
public static class OpFailedExceptionCreator {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

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

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

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // OpFailedExceptionCreator
//**************************************************************************************************

} // SqlToCsvExport
