Exemple #1
0
 private async ValueTask <Calendar> TryCatch(ReturningCalendarFunction returningCalendarFunction)
 {
     try
     {
         return(await returningCalendarFunction());
     }
     catch (InvalidCalendarInputException invalidCalendarInputException)
     {
         throw CreateAndLogValidationException(invalidCalendarInputException);
     }
     catch (NotFoundCalendarException nullCalendarException)
     {
         throw CreateAndLogValidationException(nullCalendarException);
     }
     catch (SqlException sqlException)
     {
         throw CreateAndLogCriticalDependencyException(sqlException);
     }
     catch (DbUpdateException dbUpdateException)
     {
         throw CreateAndLogDependencyException(dbUpdateException);
     }
     catch (Exception exception)
     {
         throw CreateAndLogServiceException(exception);
     }
 }
        private async ValueTask <Calendar> TryCatch(ReturningCalendarFunction returningCalendarFunction)
        {
            try
            {
                return(await returningCalendarFunction());
            }
            catch (NullCalendarException nullCalendarException)
            {
                throw CreateAndLogValidationException(nullCalendarException);
            }
            catch (InvalidCalendarException invalidCalendarException)
            {
                throw CreateAndLogValidationException(invalidCalendarException);
            }
            catch (NotFoundCalendarException nullCalendarException)
            {
                throw CreateAndLogValidationException(nullCalendarException);
            }
            catch (SqlException sqlException)
            {
                throw CreateAndLogCriticalDependencyException(sqlException);
            }
            catch (DuplicateKeyException duplicateKeyException)
            {
                var alreadyExistsCalendarException =
                    new AlreadyExistsCalendarException(duplicateKeyException);

                throw CreateAndLogValidationException(alreadyExistsCalendarException);
            }
            catch (DbUpdateConcurrencyException dbUpdateConcurrencyException)
            {
                var lockedCalendarException = new LockedCalendarException(dbUpdateConcurrencyException);

                throw CreateAndLogDependencyException(lockedCalendarException);
            }
            catch (DbUpdateException dbUpdateException)
            {
                throw CreateAndLogDependencyException(dbUpdateException);
            }
            catch (Exception exception)
            {
                var failedCalendarServiceException =
                    new FailedCalendarServiceException(exception);

                throw CreateAndLogServiceException(failedCalendarServiceException);
            }
        }