/// <summary>
///
/// </summary>
/// <param name="exception"></param>
/// <returns></returns>
public static Exception ProcessServerException(string className, string methodName, Exception exception)
{
// Gets or sets update exception
UpdateException updateException;
// Checking Exception message ends with gti exception token (GTI_EXCEPTION)
if (exception.Message.EndsWith(ERPUtilityResources.GTIExceptionWithToken) == false)
{
// Checking Exception is sql exception
SqlException sqlException = exception.InnerException as SqlException;
if (sqlException != null)
{
// Returns a new exception to service class with class name - method name - sql exception exception with corresponding exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.SqlException + sqlException.Number.ToString() + ERPUtilityResources.GTIExceptionDetailsWithToken + sqlException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
else
{
// Checking Exception is optimistic concurrency exception
OptimisticConcurrencyException concurrencyException = exception.InnerException as OptimisticConcurrencyException;
if (concurrencyException != null)
{
// Returns a new exception to service class with class name - method name - concurrency exception with corresponding exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.OptimisticConcurrencyException + concurrencyException.GetHashCode().ToString() + ERPUtilityResources.GTIExceptionDetailsWithToken + concurrencyException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
else
{
// Checking Exception is argument null exception
ArgumentNullException argException = exception as ArgumentNullException;
if (argException != null)
{
// Returns a new exception to service class with class name - method name - argument null exception with default exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.ArgumentNullException + ERPUtilityResources.DefaultErrorNumber + ERPUtilityResources.GTIExceptionDetailsWithToken + argException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
else
{
// Checking Exception is optimistic concurrency exception (concurrency exception from manager class)
concurrencyException = exception as OptimisticConcurrencyException;
if (concurrencyException != null)
{
// Returns a new exception to service class with class name - method name - concurrency exception with default exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.OptimisticConcurrencyException + ERPUtilityResources.DefaultErrorNumber + ERPUtilityResources.GTIExceptionDetailsWithToken + concurrencyException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
else
{
// Checking Exception is update exception (record already exists exception from manager class.thrown from manager class with page requirments)
updateException = exception as UpdateException;
if (updateException != null)
{
if (updateException.Message.Equals(ERPUtilityResources.DateRangeException))
{
// Returns a new exception to service class with class name - method name - record already exists exception with default exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.DateRangeException + ERPUtilityResources.DefaultErrorNumber + ERPUtilityResources.GTIExceptionDetailsWithToken + updateException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
else if (updateException.Message.Equals(ERPUtilityResources.OutofStockException))
{
// Returns a new exception to service class with class name - method name - out of stock exception with default exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.OutofStockException + ERPUtilityResources.ExceptionToken + ERPUtilityResources.DefaultErrorNumber + ERPUtilityResources.GTIExceptionDetailsWithToken + updateException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
else if (updateException.Message.Equals(ERPUtilityResources.FromToRangeException))
{
// Returns a new exception to service class with class name - method name - out of stock exception with default exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.FromToRangeException + ERPUtilityResources.ExceptionToken + ERPUtilityResources.DefaultErrorNumber + ERPUtilityResources.GTIExceptionDetailsWithToken + updateException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
else if (updateException.Message.Equals(ERPUtilityResources.ItemExistException))
{
// Returns a new exception to service class with class name - method name - out of stock exception with default exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.ItemExistException + ERPUtilityResources.ExceptionToken + ERPUtilityResources.DefaultErrorNumber + ERPUtilityResources.GTIExceptionDetailsWithToken + updateException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
else if (updateException.Message.Equals(ERPUtilityResources.NoItemException))
{
// Returns a new exception to service class with class name - method name - out of stock exception with default exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.NoItemException + ERPUtilityResources.ExceptionToken + ERPUtilityResources.DefaultErrorNumber + ERPUtilityResources.GTIExceptionDetailsWithToken + updateException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
else if (updateException.Message.Equals(ERPUtilityResources.ManyItemException))
{
// Returns a new exception to service class with class name - method name - out of stock exception with default exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.ManyItemException + ERPUtilityResources.ExceptionToken + ERPUtilityResources.DefaultErrorNumber + ERPUtilityResources.GTIExceptionDetailsWithToken + updateException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
else if (updateException.Message.Equals(ERPUtilityResources.ActivityAircraftException))
{
// Returns a new exception to service class with class name - method name - out of stock exception with default exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.ActivityAircraftException + ERPUtilityResources.ExceptionToken + ERPUtilityResources.DefaultErrorNumber + ERPUtilityResources.GTIExceptionDetailsWithToken + updateException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
else if (updateException.Message.Equals(ERPUtilityResources.ShiftAttendanceExistException))
{
// Returns a new exception to service class with class name - method name - out of stock exception with default exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.ShiftAttendanceExistException + ERPUtilityResources.ExceptionToken + ERPUtilityResources.DefaultErrorNumber + ERPUtilityResources.GTIExceptionDetailsWithToken + updateException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
else
{
// Returns a new exception to service class with class name - method name - record already exists exception with default exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.RecordAlreadyExistsException + ERPUtilityResources.DefaultErrorNumber + ERPUtilityResources.GTIExceptionDetailsWithToken + updateException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
}
else
{
// Returns a new exception to service class with class name - method name - unknown error with default exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.UnknownError + ERPUtilityResources.DefaultErrorNumber + ERPUtilityResources.GTIExceptionDetailsWithToken + exception.Message + ERPUtilityResources.GTIExceptionWithToken);
}
}
}
}
}
}
else
{
return exception;
}
}
///
/// </summary>
/// <param name="exception"></param>
/// <returns></returns>
public static Exception ProcessServerException(string className, string methodName, Exception exception)
{
// Gets or sets update exception
UpdateException updateException;
// Checking Exception message ends with gti exception token (GTI_EXCEPTION)
if (exception.Message.EndsWith(ERPUtilityResources.GTIExceptionWithToken) == false)
{
// Checking Exception is sql exception
SqlException sqlException = exception.InnerException as SqlException;
if (sqlException != null)
{
// Returns a new exception to service class with class name - method name - sql exception exception with corresponding exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.SqlException + sqlException.Number.ToString() + ERPUtilityResources.GTIExceptionDetailsWithToken + sqlException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
else
{
// Checking Exception is optimistic concurrency exception
OptimisticConcurrencyException concurrencyException = exception.InnerException as OptimisticConcurrencyException;
if (concurrencyException != null)
{
// Returns a new exception to service class with class name - method name - concurrency exception with corresponding exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.OptimisticConcurrencyException + concurrencyException.GetHashCode().ToString() + ERPUtilityResources.GTIExceptionDetailsWithToken + concurrencyException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
else
{
// Checking Exception is argument null exception
ArgumentNullException argException = exception as ArgumentNullException;
if (argException != null)
{
// Returns a new exception to service class with class name - method name - argument null exception with default exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.ArgumentNullException + ERPUtilityResources.DefaultErrorNumber + ERPUtilityResources.GTIExceptionDetailsWithToken + argException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
else
{
// Checking Exception is optimistic concurrency exception (concurrency exception from manager class)
concurrencyException = exception as OptimisticConcurrencyException;
if (concurrencyException != null)
{
// Returns a new exception to service class with class name - method name - concurrency exception with default exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.OptimisticConcurrencyException + ERPUtilityResources.DefaultErrorNumber + ERPUtilityResources.GTIExceptionDetailsWithToken + concurrencyException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
else
{
// Checking Exception is update exception (record already exists exception from manager class.thrown from manager class with page requirments)
updateException = exception as UpdateException;
if (updateException != null)
{
if (updateException.Message.Equals(ERPUtilityResources.DateRangeException))
{
// Returns a new exception to service class with class name - method name - record already exists exception with default exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.DateRangeException + ERPUtilityResources.DefaultErrorNumber + ERPUtilityResources.GTIExceptionDetailsWithToken + updateException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
else if (updateException.Message.Equals(ERPUtilityResources.OutofStockException))
{
// Returns a new exception to service class with class name - method name - out of stock exception with default exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.OutofStockException + ERPUtilityResources.ExceptionToken + ERPUtilityResources.DefaultErrorNumber + ERPUtilityResources.GTIExceptionDetailsWithToken + updateException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
else if (updateException.Message.Equals(ERPUtilityResources.FromToRangeException))
{
// Returns a new exception to service class with class name - method name - out of stock exception with default exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.FromToRangeException + ERPUtilityResources.ExceptionToken + ERPUtilityResources.DefaultErrorNumber + ERPUtilityResources.GTIExceptionDetailsWithToken + updateException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
else if (updateException.Message.Equals(ERPUtilityResources.ItemExistException))
{
// Returns a new exception to service class with class name - method name - out of stock exception with default exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.ItemExistException + ERPUtilityResources.ExceptionToken + ERPUtilityResources.DefaultErrorNumber + ERPUtilityResources.GTIExceptionDetailsWithToken + updateException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
else if (updateException.Message.Equals(ERPUtilityResources.NoItemException))
{
// Returns a new exception to service class with class name - method name - out of stock exception with default exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.NoItemException + ERPUtilityResources.ExceptionToken + ERPUtilityResources.DefaultErrorNumber + ERPUtilityResources.GTIExceptionDetailsWithToken + updateException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
else if (updateException.Message.Equals(ERPUtilityResources.ManyItemException))
{
// Returns a new exception to service class with class name - method name - out of stock exception with default exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.ManyItemException + ERPUtilityResources.ExceptionToken + ERPUtilityResources.DefaultErrorNumber + ERPUtilityResources.GTIExceptionDetailsWithToken + updateException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
else if (updateException.Message.Equals(ERPUtilityResources.ActivityAircraftException))
{
// Returns a new exception to service class with class name - method name - out of stock exception with default exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.ActivityAircraftException + ERPUtilityResources.ExceptionToken + ERPUtilityResources.DefaultErrorNumber + ERPUtilityResources.GTIExceptionDetailsWithToken + updateException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
else if (updateException.Message.Equals(ERPUtilityResources.ShiftAttendanceExistException))
{
// Returns a new exception to service class with class name - method name - out of stock exception with default exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.ShiftAttendanceExistException + ERPUtilityResources.ExceptionToken + ERPUtilityResources.DefaultErrorNumber + ERPUtilityResources.GTIExceptionDetailsWithToken + updateException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
else
{
// Returns a new exception to service class with class name - method name - record already exists exception with default exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.RecordAlreadyExistsException + ERPUtilityResources.DefaultErrorNumber + ERPUtilityResources.GTIExceptionDetailsWithToken + updateException.Message + ERPUtilityResources.GTIExceptionWithToken);
}
}
else
{
// Returns a new exception to service class with class name - method name - unknown error with default exception number as exception message
return new Exception(className + ERPUtilityResources.ExceptionToken + methodName + ERPUtilityResources.ExceptionToken + ERPUtilityResources.UnknownError + ERPUtilityResources.DefaultErrorNumber + ERPUtilityResources.GTIExceptionDetailsWithToken + exception.Message + ERPUtilityResources.GTIExceptionWithToken);
}
}
}
}
}
}
else
{
return exception;
}
}
No comments:
Post a Comment