diff --git a/Sources/App/Program.cs b/Sources/App/Program.cs index d80f387..5d89f6a 100644 --- a/Sources/App/Program.cs +++ b/Sources/App/Program.cs @@ -220,9 +220,23 @@ namespace App Console.WriteLine("create a face with an image uri, or enter 'ok' if you're finished"); menuChoiceNewFaces = Console.ReadLine(); - if (menuChoiceNewFaces != "ok") faces.Add(new(new Uri(menuChoiceNewFaces))); + if (menuChoiceNewFaces != "ok") + { + try + { + faces.Add(new(new Uri(menuChoiceNewFaces))); + } + catch (ArgumentNullException ex) + { + Console.WriteLine(ex.Message); + } + catch (UriFormatException ex) + { + Console.WriteLine("that URI was not valid"); + Console.WriteLine(ex.Message); + } + } } - die = new ImageDie(faces.ToArray()); return die; } diff --git a/Sources/Data/Stub.cs b/Sources/Data/Stub.cs index 3d4e934..e421177 100644 --- a/Sources/Data/Stub.cs +++ b/Sources/Data/Stub.cs @@ -43,12 +43,14 @@ namespace Data monopolyDice.Add(new ColorDie(colorFaces)); + string rootPath = "https://unsplash.com/photos/"; + ImageFace[] imageFaces = new ImageFace[] { - new(new Uri("https://unsplash.com/photos/TLD6iCOlyb0")), - new(new Uri("https://unsplash.com/photos/rTZW4f02zY8")), - new(new Uri("https://unsplash.com/photos/Hyu76loQLdk")), - new(new Uri("https://unsplash.com/photos/A_Ncbi-RH6s")), + new(new Uri(rootPath + "TLD6iCOlyb0")), + new(new Uri(rootPath + "rTZW4f02zY8")), + new(new Uri(rootPath + "Hyu76loQLdk")), + new(new Uri(rootPath + "A_Ncbi-RH6s")), }; monopolyDice.Add(new ImageDie(imageFaces));