public async Task ShouldThrowTeacherViewServiceExceptionWhenServiceErrorOccursAndLogItAsync()
        {
            var serviceException = new Exception();

            var failedTeacherViewServiceException =
                new FailedTeacherViewServiceException(serviceException);

            var expectedTeacherViewServiceException =
                new TeacherViewServiceException(failedTeacherViewServiceException);

            this.teacherServiceMock.Setup(service =>
                                          service.RetrieveAllTeachersAsync())
            .ThrowsAsync(serviceException);

            ValueTask <List <TeacherView> > retrieveAllTeacherViewsTask =
                this.teacherViewService.RetrieveAllTeacherViewsAsync();

            await Assert.ThrowsAsync <TeacherViewServiceException>(() =>
                                                                   retrieveAllTeacherViewsTask.AsTask());

            this.teacherServiceMock.Verify(service =>
                                           service.RetrieveAllTeachersAsync(),
                                           Times.Once);

            this.loggingBrokerMock.Verify(broker =>
                                          broker.LogError(It.Is(SameExceptionAs(
                                                                    expectedTeacherViewServiceException))),
                                          Times.Once);

            this.teacherServiceMock.VerifyNoOtherCalls();
            this.loggingBrokerMock.VerifyNoOtherCalls();
        }
        private async ValueTask <List <TeacherView> > TryCatch(ReturningTeachersViewsFunction returningTeachersViewsFunction)
        {
            try
            {
                return(await returningTeachersViewsFunction());
            }
            catch (TeacherDependencyException teacherDependencyException)
            {
                throw CreateAndLogDependencyException(teacherDependencyException);
            }
            catch (TeacherServiceException teacherServiceException)
            {
                throw CreateAndLogDependencyException(teacherServiceException);
            }
            catch (Exception serviceException)
            {
                var failedTeacherViewServiceException =
                    new FailedTeacherViewServiceException(serviceException);

                throw CreateAndLogServiceException(failedTeacherViewServiceException);
            }
        }