From 93362d3695b808fd5d06388e6b42b7791e890797 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Mon, 9 Sep 2024 13:11:56 +0200 Subject: [PATCH] Don't crash on ship delete API error --- src/BreCalClient/ShipListDialog.xaml.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/BreCalClient/ShipListDialog.xaml.cs b/src/BreCalClient/ShipListDialog.xaml.cs index a4149e2..7ad18ed 100644 --- a/src/BreCalClient/ShipListDialog.xaml.cs +++ b/src/BreCalClient/ShipListDialog.xaml.cs @@ -49,8 +49,15 @@ namespace BreCalClient { if (!shipmodel.Ship.Deleted) { - if (this.ShipApi != null) - await this.ShipApi.ShipDeleteAsync(shipmodel.Ship.Id); + try + { + if (this.ShipApi != null) + await this.ShipApi.ShipDeleteAsync(shipmodel.Ship.Id); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); + } BreCalLists.Ships.Remove(shipmodel); // remove from "selectable" ships shipmodel.Ship.Deleted = true; // set deleted marker on working instance this.dataGridShips.ItemsSource = null;