Skip to content

Commit

Permalink
Prevent app from crashing when server is not available during auto-load
Browse files Browse the repository at this point in the history
  • Loading branch information
cezarypiatek committed Jan 21, 2024
1 parent ad0790c commit f2d8535
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
10 changes: 10 additions & 0 deletions src/WireMockInspector/ReactiveEx.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;
using System.Reactive.Linq;

namespace WireMockInspector;

public static class ReactiveEx
{
public static IObservable<T> DiscardExceptions<T>(this IObservable<T> observable)
=> observable.Catch(Observable.Empty<T>());
}
11 changes: 7 additions & 4 deletions src/WireMockInspector/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@ public MainWindow()
if (Settings.AutoLoad)
{
ViewModel.LoadRequestsCommand.Execute().ObserveOn(RxApp.MainThreadScheduler).Subscribe(_ =>
{
ViewModel.RequestSearchTerm = Settings.RequestFilters;
}).DisposeWith(disposables);
ViewModel.LoadRequestsCommand.Execute()
.ObserveOn(RxApp.MainThreadScheduler)
.DiscardExceptions()
.Subscribe(_ =>
{
ViewModel.RequestSearchTerm = Settings.RequestFilters;
}).DisposeWith(disposables);
}
if (string.IsNullOrWhiteSpace(Settings.InstanceName) == false)
Expand Down

0 comments on commit f2d8535

Please sign in to comment.