From b2db59f970fc0041e315c91f01b2c80062adfb95 Mon Sep 17 00:00:00 2001 From: "HOT-ROD\\craig" Date: Sat, 4 Aug 2018 01:23:14 +0100 Subject: [PATCH] Added TextIsValid logic to RequestTextFromFile function. --- WetPancake/ProductServices.fs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/WetPancake/ProductServices.fs b/WetPancake/ProductServices.fs index dee5c06..bbbe3bd 100644 --- a/WetPancake/ProductServices.fs +++ b/WetPancake/ProductServices.fs @@ -44,7 +44,7 @@ module Pancake = | :? InvalidOperationException -> return text } - let TextInFileIsValid filePath = + let TextInFileIsValidAsync filePath = async { return DataAccess.LoadFile filePath |> TextContainsValidEndToken } @@ -153,7 +153,9 @@ module Pancake = GibberishLevelIsValid gibberishLevel |> ignore SentencesIsValid sentences |> ignore FilePathIsValid filePath |> ignore - // pattern match the TextInFileIsValid function + let! textIsValid = TextInFileIsValidAsync filePath + if textIsValid = true then ignore () + else failwith @"The .txt file does not contain an end token ('.', '!' or '?')." let data = LoadFile filePath |> ApplyStandardSetup @@ -163,6 +165,7 @@ module Pancake = with | :? ArgumentException as ex -> return ex.Message | :? FileNotFoundException as ex -> return ex.Message + | :? SystemException as ex -> return ex.Message } ///