using System;

using CommonHelpers;

namespace CommonHelpers {

//**************************************************************************************************
partial class LnkVariableProcessor {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

class VariableProcessingException: HException
{
   public VariableProcessingException(string message): base( message ){}
}

//**************************************************************************************************

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

//**************************************************************************************************

/// <exception cref="ArgumentNullException" />
VariableProcessingException CreateExceptionWithPosInfo(string message)
{
   return CreateExceptionWithPosInfo( Pos, message );
}
/// <exception cref="ArgumentNullException" />
VariableProcessingException CreateExceptionWithPosInfo( string messageFmt,
                                                        params object[] parameters )
{
   return CreateExceptionWithPosInfo( Pos, messageFmt, parameters );
}
/// <exception cref="ArgumentNullException" />
VariableProcessingException CreateExceptionWithPosInfo(Exception error)
{
   return CreateExceptionWithPosInfo( Pos, error );
}

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

/// <exception cref="ArgumentNullException" />
VariableProcessingException CreateExceptionWithPosInfo(int position,string message)
{
   return VariableProcessingExceptionCreator.Create(
      "{0}\n"+
      "({1})",
      message,
      string.Format( HLnkConverter.Verbose.POSITION_FROM_BEGINNING_OF_TXT_STRING_0,
         StartingPosInLine + position + 1 ));
}
/// <exception cref="ArgumentNullException" />
VariableProcessingException CreateExceptionWithPosInfo( int position,
                                                        string messageFmt,
                                                        params object[] parameters )
{
   HArgChecking.VerifyNotNulls( messageFmt, parameters );
   return CreateExceptionWithPosInfo( position, string.Format(messageFmt,parameters) );
}
/// <exception cref="ArgumentNullException" />
VariableProcessingException CreateExceptionWithPosInfo(int position,Exception error)
{
   HArgChecking.VerifyNotNulls( error );
   return CreateExceptionWithPosInfo( position, error.Message );
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // LnkVariableProcessor
//**************************************************************************************************

} // CommonHelpers
