Skip to content

Commit

Permalink
FEA: added error message that shows if a given config was not found
Browse files Browse the repository at this point in the history
  • Loading branch information
legezam committed May 14, 2021
1 parent 6881362 commit 4e7e15f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/MechSym.SnapperReplicator/Snapper.Serialization.fs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ module Config =

let parse (result: Map<string, Config list>) =
result.["configs"]
|> List.find (fun config -> config.Name = configName)
|> List.tryFind (fun config -> config.Name = configName)
|> Option.defaultWith (fun () ->
let availableConfigs = result.["configs"] |> List.map (fun config -> config.Name.Value) |> String.concat ", "
let message = $"Cannot find config '{configName.Value}'. Available configs: {availableConfigs}"
failwith message)

Decode.fromString configsDecoder snapperListConfigsOutput
|> Result.map parse
Expand Down

0 comments on commit 4e7e15f

Please sign in to comment.