Skip to content

Commit 101bd09

Browse files
committed
Changed order outputs and downloads are done to prevent apod metadata from outputting after an error
1 parent a19f1b3 commit 101bd09

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

Program.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,23 @@ async static Task Main(string[] args)
3131

3232
Console.WriteLine("Astronomy Picture Of The Day | Program Created by Weston McNamara\n");
3333

34-
//Ouput the title, date, and an image explanation
35-
Console.WriteLine(apod.title);
36-
Console.WriteLine(apod.date + "\n\n");
37-
Console.WriteLine(apod.explanation + "\n\n");
38-
3934
//After displaying that, download the background, and set the desktop background with the new image.
4035
using (var client = new WebClient())
4136
{
4237
Console.WriteLine("Downloading Background...");
4338
client.DownloadFile(apod.hdurl, "bg.jpg");
4439
SetDesktopBackground(Path.GetFullPath("bg.jpg"));
45-
Console.WriteLine("Background Updated!");
40+
Console.WriteLine("Background Updated!\n");
4641
}
42+
43+
//Ouput the title, date, and an image explanation
44+
Console.WriteLine(apod.title);
45+
Console.WriteLine(apod.date + "\n\n");
46+
Console.WriteLine(apod.explanation + "\n");
4747
}
4848
catch (Exception e)
4949
{
50+
5051
//Console.WriteLine("\nException Caught!");
5152
//Console.WriteLine("Message :{0} ", e.Message);
5253
Console.WriteLine("\nThe APOD today is not a format that can be set to a desktop background, such as a video. Please visit the official APOD website to view todays APOD. \n\nhttps://apod.nasa.gov/apod/astropix.html" );

0 commit comments

Comments
 (0)