Skip to content

Commit 58d860b

Browse files
committed
add error handling to wikiservice
1 parent 1771dcc commit 58d860b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

CompactGUI/Services/WikiService.vb

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,18 @@ Public Class WikiService : Implements IWikiService
2323
Dim httpClient As New HttpClient
2424
Dim res = Await httpClient.GetStreamAsync(dlPath)
2525

26-
Using fs As New IO.FileStream(JSONFile.FullName, IO.FileMode.Create)
27-
Await res.CopyToAsync(fs)
28-
End Using
26+
Try
27+
Using fs As New IO.FileStream(JSONFile.FullName, IO.FileMode.Create)
28+
Await res.CopyToAsync(fs)
29+
End Using
30+
31+
Catch ex As IO.IOException
32+
Debug.WriteLine("Could not update JSON file: file is in use.")
33+
Return
34+
Finally
35+
httpClient.Dispose()
36+
End Try
2937

30-
httpClient.Dispose()
3138

3239
SettingsHandler.AppSettings.ResultsDBLastUpdated = DateTime.Now
3340
Settings.Save()

0 commit comments

Comments
 (0)