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 =
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 =

15
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`` () =

5
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

Loading…
Cancel
Save