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

namespace CommonHelpers {

//**************************************************************************************************
/// <summary>
/// </summary>
[HDbOrmType]
public static partial class HDBExceptionsSP {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/// <exception cref="ArgumentNullException" />
public static HDatabaseException ExpectedResultSetWasNotReceived(string procedureName) =>
   AppendProcedureName( HDBExceptions.ExpectedResultSetWasNotReceived, procedureName );

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

/// <exception cref="ArgumentNullException" />
public static HDatabaseException NotMoreThanOneRecordWasExpectedInRSet(string procedureName) =>
   AppendProcedureName( HDBExceptions.NotMoreThanOneRecordWasExpectedInRSet, procedureName );
/// <exception cref="ArgumentNullException" />
public static HDatabaseException NotMoreThanOneRecordWasExpectedIn1stRSet(string procedureName) =>
   AppendProcedureName( HDBExceptions.NotMoreThanOneRecordWasExpectedIn1stRSet, procedureName );
/// <exception cref="ArgumentNullException" />
public static HDatabaseException NotMoreThanOneRecordWasExpectedIn2ndRSet(string procedureName) =>
   AppendProcedureName( HDBExceptions.NotMoreThanOneRecordWasExpectedIn2ndRSet, procedureName );
/// <exception cref="ArgumentNullException" />
public static HDatabaseException NotMoreThanOneRecordWasExpectedIn3rdRSet(string procedureName) =>
   AppendProcedureName( HDBExceptions.NotMoreThanOneRecordWasExpectedIn3rdRSet, procedureName );
/// <exception cref="ArgumentNullException" />
public static HDatabaseException NotMoreThanOneRecordWasExpectedIn4thRSet(string procedureName) =>
   AppendProcedureName( HDBExceptions.NotMoreThanOneRecordWasExpectedIn4thRSet, procedureName );
/// <exception cref="ArgumentNullException" />
public static HDatabaseException NotMoreThanOneRecordWasExpectedIn5thRSet(string procedureName) =>
   AppendProcedureName( HDBExceptions.NotMoreThanOneRecordWasExpectedIn5thRSet, procedureName );

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

/// <exception cref="ArgumentNullException" />
public static HDatabaseException ExactlyOneRecordWasExpectedInRSet(string procedureName) =>
   AppendProcedureName( HDBExceptions.ExactlyOneRecordWasExpectedInRSet, procedureName );
/// <exception cref="ArgumentNullException" />
public static HDatabaseException ExactlyOneRecordWasExpectedIn1stRSet(string procedureName) =>
   AppendProcedureName( HDBExceptions.ExactlyOneRecordWasExpectedIn1stRSet, procedureName );
/// <exception cref="ArgumentNullException" />
public static HDatabaseException ExactlyOneRecordWasExpectedIn2ndRSet(string procedureName) =>
   AppendProcedureName( HDBExceptions.ExactlyOneRecordWasExpectedIn2ndRSet, procedureName );
/// <exception cref="ArgumentNullException" />
public static HDatabaseException ExactlyOneRecordWasExpectedIn3rdRSet(string procedureName) =>
   AppendProcedureName( HDBExceptions.ExactlyOneRecordWasExpectedIn3rdRSet, procedureName );
/// <exception cref="ArgumentNullException" />
public static HDatabaseException ExactlyOneRecordWasExpectedIn4thRSet(string procedureName) =>
   AppendProcedureName( HDBExceptions.ExactlyOneRecordWasExpectedIn4thRSet, procedureName );
/// <exception cref="ArgumentNullException" />
public static HDatabaseException ExactlyOneRecordWasExpectedIn5thRSet(string procedureName) =>
   AppendProcedureName( HDBExceptions.ExactlyOneRecordWasExpectedIn5thRSet, procedureName );

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

/// <exception cref="ArgumentNullException" />
public static HDatabaseException AtLeastOneRecordWasExpectedInRSet(string procedureName) =>
   AppendProcedureName( HDBExceptions.AtLeastOneRecordWasExpectedInRSet, procedureName );
/// <exception cref="ArgumentNullException" />
public static HDatabaseException AtLeastOneRecordWasExpectedIn1stRSet(string procedureName) =>
   AppendProcedureName( HDBExceptions.AtLeastOneRecordWasExpectedIn1stRSet, procedureName );
/// <exception cref="ArgumentNullException" />
public static HDatabaseException AtLeastOneRecordWasExpectedIn2ndRSet(string procedureName) =>
   AppendProcedureName( HDBExceptions.AtLeastOneRecordWasExpectedIn2ndRSet, procedureName );
/// <exception cref="ArgumentNullException" />
public static HDatabaseException AtLeastOneRecordWasExpectedIn3rdRSet(string procedureName) =>
   AppendProcedureName( HDBExceptions.AtLeastOneRecordWasExpectedIn3rdRSet, procedureName );
/// <exception cref="ArgumentNullException" />
public static HDatabaseException AtLeastOneRecordWasExpectedIn4thRSet(string procedureName) =>
   AppendProcedureName( HDBExceptions.AtLeastOneRecordWasExpectedIn4thRSet, procedureName );
/// <exception cref="ArgumentNullException" />
public static HDatabaseException AtLeastOneRecordWasExpectedIn5thRSet(string procedureName) =>
   AppendProcedureName( HDBExceptions.AtLeastOneRecordWasExpectedIn5thRSet, procedureName );

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

/// <exception cref="ArgumentNullException" />
public static HDatabaseException MoreThanOneRecordWereExpectedInRSet(string procedureName) =>
   AppendProcedureName( HDBExceptions.MoreThanOneRecordWereExpectedInRSet, procedureName );
/// <exception cref="ArgumentNullException" />
public static HDatabaseException MoreThanOneRecordWereExpectedIn1stRSet(string procedureName) =>
   AppendProcedureName( HDBExceptions.MoreThanOneRecordWereExpectedIn1stRSet, procedureName );
/// <exception cref="ArgumentNullException" />
public static HDatabaseException MoreThanOneRecordWereExpectedIn2ndRSet(string procedureName) =>
   AppendProcedureName( HDBExceptions.MoreThanOneRecordWereExpectedIn2ndRSet, procedureName );
/// <exception cref="ArgumentNullException" />
public static HDatabaseException MoreThanOneRecordWereExpectedIn3rdRSet(string procedureName) =>
   AppendProcedureName( HDBExceptions.MoreThanOneRecordWereExpectedIn3rdRSet, procedureName );
/// <exception cref="ArgumentNullException" />
public static HDatabaseException MoreThanOneRecordWereExpectedIn4thRSet(string procedureName) =>
   AppendProcedureName( HDBExceptions.MoreThanOneRecordWereExpectedIn4thRSet, procedureName );
/// <exception cref="ArgumentNullException" />
public static HDatabaseException MoreThanOneRecordWereExpectedIn5thRSet(string procedureName) =>
   AppendProcedureName( HDBExceptions.MoreThanOneRecordWereExpectedIn5thRSet, procedureName );

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

/// <exception cref="ArgumentNullException" />
public static HDatabaseException SecondResultSetWasExpected(string procedureName) =>
   AppendProcedureName( HDBExceptions.SecondResultSetWasExpected, procedureName );
/// <exception cref="ArgumentNullException" />
public static HDatabaseException ThirdResultSetWasExpected(string procedureName) =>
   AppendProcedureName( HDBExceptions.ThirdResultSetWasExpected, procedureName );
/// <exception cref="ArgumentNullException" />
public static HDatabaseException FourthResultSetWasExpected(string procedureName) =>
   AppendProcedureName( HDBExceptions.FourthResultSetWasExpected, procedureName );
/// <exception cref="ArgumentNullException" />
public static HDatabaseException FifthResultSetWasExpected(string procedureName) =>
   AppendProcedureName( HDBExceptions.FifthResultSetWasExpected, procedureName );

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

/// <exception cref="ArgumentNullException" />
public static HDatabaseException InconsistentResult(string procedureName) =>
   AppendProcedureName( HDBExceptions.InconsistentQueryResult, procedureName );

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

/// <exception cref="ArgumentNullException" />
static HDatabaseException AppendProcedureName(HDatabaseException e,string procedureName)
{
   HArgChecking.VerifyNotNulls( e, procedureName );
   return HDBExceptionCreator.Create(
      "{0}\n"+
      "({1}: [{2}].)",
      e.Message,
      HLocal.TEXT( "Stored procedure", "Хранимая процедура" ),
      procedureName );
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // HDBExceptionsSP
//**************************************************************************************************

} // CommonHelpers
