Browse Source

edit error messages and add try block to draw-image.

master
Craig Oates 6 years ago
parent
commit
f6f1fdeb6c
  1. 2
      SmoulderingBeachBall/InternalServices.fs
  2. 15
      SmoulderingBeachBallCLI/ConsoleCommands.fs
  3. 5
      SmoulderingBeachBallCLI/Validation.fs

2
SmoulderingBeachBall/InternalServices.fs

@ -9,7 +9,7 @@
let validateDimension dimension = let validateDimension dimension =
match dimension with match dimension with
| dimension when dimension <= 0 -> | 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 = let validateDirectory filePath =

15
SmoulderingBeachBallCLI/ConsoleCommands.fs

@ -3,11 +3,8 @@
module ConsoleCommands = module ConsoleCommands =
open System open System
open Console.Waterworks
open SmoulderingBeachBall.Domain
open SmoulderingBeachBall.Services open SmoulderingBeachBall.Services
open Validation open Validation
open System.Drawing
let showEndOfCommandMessage = "[INFO.] Execution completed." let showEndOfCommandMessage = "[INFO.] Execution completed."
@ -16,10 +13,14 @@
let exit () = Environment.Exit (Environment.ExitCode) let exit () = Environment.Exit (Environment.ExitCode)
let ``draw-image`` imgWidth imgHeight mainColour path = let ``draw-image`` imgWidth imgHeight mainColour path =
buildBasicSpec imgWidth imgHeight mainColour path try
|> makeImage buildBasicSpec imgWidth imgHeight mainColour path
|> Async.RunSynchronously |> makeImage
showEndOfCommandMessage |> Async.RunSynchronously
showEndOfCommandMessage
with
| :? ArgumentException as ex -> ex.Message
| _ as ex -> ex.Message
let ``draw-borderedImage`` () = let ``draw-borderedImage`` () =

5
SmoulderingBeachBallCLI/Validation.fs

@ -26,8 +26,9 @@
colourList colourList
|> Map.find (colour.ToLower()) |> Map.find (colour.ToLower())
| false -> | false ->
invalidArg "Colour" "[ERROR] The colour specifed is invalid." invalidArg "Colour"
// "Please use the ListAvailableColours command for a list"? (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) = let parsePath (path: string) =
match path with match path with

Loading…
Cancel
Save