Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationService.cs =================================================================== diff -u -ra0e847cda510ac315d678871c6d30b8225ba7b55 -raaeb6b78529e3c46c5035b6bad846b53ec64f1ca --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationService.cs (.../GrassCoverErosionInwardsCalculationService.cs) (revision a0e847cda510ac315d678871c6d30b8225ba7b55) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationService.cs (.../GrassCoverErosionInwardsCalculationService.cs) (revision aaeb6b78529e3c46c5035b6bad846b53ec64f1ca) @@ -439,19 +439,27 @@ generalInput, hydraulicBoundaryDatabaseFilePath); - bool dikeHeightCalculated = CalculateDikeHeight(dikeHeightCalculationInput, calculation.Name); + var dikeHeightCalculated = true; - if (canceled) + try { - return null; + PerformCalculation(() => dikeHeightCalculator.Calculate(dikeHeightCalculationInput), + () => dikeHeightCalculator.LastErrorFileContent, + () => dikeHeightCalculator.OutputDirectory, + calculation.Name, + Resources.GrassCoverErosionInwardsCalculationService_DikeHeight); } + catch (HydraRingCalculationException) + { + dikeHeightCalculated = false; + } - if (dikeHeightCalculated) + if (canceled || !dikeHeightCalculated) { - return CreateDikeHeightAssessmentOutput(calculation.Name, dikeHeightCalculationInput.Beta, norm); + return null; } - return null; + return CreateDikeHeightAssessmentOutput(calculation.Name, dikeHeightCalculationInput.Beta, norm); } /// @@ -510,57 +518,6 @@ } /// - /// Performs the dike height calculation. - /// - /// The input of the dike height calculation. - /// The name of the calculation. - /// True when the calculation was successful. False otherwise. - private bool CalculateDikeHeight(DikeHeightCalculationInput dikeHeightCalculationInput, string calculationName) - { - var exceptionThrown = false; - var dikeHeightCalculated = false; - if (!canceled) - { - try - { - dikeHeightCalculator.Calculate(dikeHeightCalculationInput); - } - catch (HydraRingCalculationException) - { - if (!canceled) - { - string lastErrorContent = dikeHeightCalculator.LastErrorFileContent; - if (string.IsNullOrEmpty(lastErrorContent)) - { - log.ErrorFormat(Resources.GrassCoverErosionInwardsCalculationService_Calculate_Error_in_hbn_grass_cover_erosion_inwards_0_calculation_no_error_report, calculationName); - } - else - { - log.ErrorFormat(Resources.GrassCoverErosionInwardsCalculationService_Calculate_Error_in_hbn_grass_cover_erosion_inwards_0_calculation_click_details_for_last_error_report_1, calculationName, lastErrorContent); - } - - exceptionThrown = true; - } - } - finally - { - string lastErrorFileContent = dikeHeightCalculator.LastErrorFileContent; - if (CalculationServiceHelper.HasErrorOccurred(canceled, exceptionThrown, lastErrorFileContent)) - { - log.ErrorFormat(Resources.GrassCoverErosionInwardsCalculationService_Calculate_Error_in_hbn_grass_cover_erosion_inwards_0_calculation_click_details_for_last_error_report_1, calculationName, lastErrorFileContent); - } - if (!exceptionThrown && string.IsNullOrEmpty(lastErrorFileContent)) - { - dikeHeightCalculated = true; - } - - log.InfoFormat(Resources.GrassCoverErosionInwardsCalculationService_CalculateDikeHeight_calculation_temporary_directory_can_be_found_on_location_0, dikeHeightCalculator.OutputDirectory); - } - } - return dikeHeightCalculated; - } - - /// /// Creates the output of a dike height calculation. /// /// The name of the calculation.