From f6f1fdeb6cd30b1eebfc023f2d84a5357fd967c8 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sun, 2 Sep 2018 02:21:51 +0100 Subject: [PATCH] edit error messages and add try block to draw-image. --- SmoulderingBeachBall/InternalServices.fs | 2 +- SmoulderingBeachBallCLI/ConsoleCommands.fs | 15 ++++++++------- SmoulderingBeachBallCLI/Validation.fs | 5 +++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/SmoulderingBeachBall/InternalServices.fs b/SmoulderingBeachBall/InternalServices.fs index 768eece..7a5e334 100644 --- a/SmoulderingBeachBall/InternalServices.fs +++ b/SmoulderingBeachBall/InternalServices.fs @@ -9,7 +9,7 @@ let validateDimension dimension = match dimension with | dimension when dimension <= 0 -> - invalidArg "dimension" "The width and height must be greater than 0." + invalidArg "dimension" "[ERROR] The width and height must be greater than 0." | _ -> () let validateDirectory filePath = diff --git a/SmoulderingBeachBallCLI/ConsoleCommands.fs b/SmoulderingBeachBallCLI/ConsoleCommands.fs index ec26d9b..f14b253 100644 --- a/SmoulderingBeachBallCLI/ConsoleCommands.fs +++ b/SmoulderingBeachBallCLI/ConsoleCommands.fs @@ -3,11 +3,8 @@ module ConsoleCommands = open System - open Console.Waterworks - open SmoulderingBeachBall.Domain open SmoulderingBeachBall.Services open Validation - open System.Drawing let showEndOfCommandMessage = "[INFO.] Execution completed." @@ -16,10 +13,14 @@ let exit () = Environment.Exit (Environment.ExitCode) let ``draw-image`` imgWidth imgHeight mainColour path = - buildBasicSpec imgWidth imgHeight mainColour path - |> makeImage - |> Async.RunSynchronously - showEndOfCommandMessage + try + buildBasicSpec imgWidth imgHeight mainColour path + |> makeImage + |> Async.RunSynchronously + showEndOfCommandMessage + with + | :? ArgumentException as ex -> ex.Message + | _ as ex -> ex.Message let ``draw-borderedImage`` () = diff --git a/SmoulderingBeachBallCLI/Validation.fs b/SmoulderingBeachBallCLI/Validation.fs index 7c3696a..acf629a 100644 --- a/SmoulderingBeachBallCLI/Validation.fs +++ b/SmoulderingBeachBallCLI/Validation.fs @@ -26,8 +26,9 @@ colourList |> Map.find (colour.ToLower()) | false -> - invalidArg "Colour" "[ERROR] The colour specifed is invalid." - // "Please use the ListAvailableColours command for a list"? + invalidArg "Colour" + (String.Concat("[ERROR] The colour specifed is invalid.\n", + "Please use the 'list-colours' command to see what you can use.")) let parsePath (path: string) = match path with