Mercurial > repos > IBBoard.WarFoundry.GUI.GTK
comparison FrmMainWindow.cs @ 159:89e2442bbb60
Re #417: Improve install/first use experience
* Handle errors in GTK# interface
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 19 May 2012 20:26:44 +0100 |
parents | 6b4cc1fc3f42 |
children | 354c1d2ad086 |
comparison
equal
deleted
inserted
replaced
158:6b4cc1fc3f42 | 159:89e2442bbb60 |
---|---|
1308 fileDialog.Hide(); | 1308 fileDialog.Hide(); |
1309 fileDialog.Dispose(); | 1309 fileDialog.Dispose(); |
1310 | 1310 |
1311 if (response == (int)ResponseType.Accept) | 1311 if (response == (int)ResponseType.Accept) |
1312 { | 1312 { |
1313 List<Exception> exceptions = new List<Exception>(); | |
1314 | |
1313 foreach (string filePath in filePaths) | 1315 foreach (string filePath in filePaths) |
1314 { | 1316 { |
1315 WarFoundryLoader.AddNewDataFile(filePath); | 1317 try |
1318 { | |
1319 WarFoundryLoader.AddNewDataFile(filePath); | |
1320 } | |
1321 catch (Exception ex) | |
1322 { | |
1323 exceptions.Add(ex); | |
1324 } | |
1316 } | 1325 } |
1317 | 1326 |
1318 WarFoundryLoader.GetDefault().LoadFiles(); | 1327 WarFoundryLoader.GetDefault().LoadFiles(); |
1319 } | 1328 |
1329 if (exceptions.Count > 0) | |
1330 { | |
1331 string errorMsg = MakeAddDataFileFailedMessage(exceptions); | |
1332 MessageDialog dialog = new MessageDialog(null, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, false, errorMsg); | |
1333 dialog.Run(); | |
1334 dialog.Hide(); | |
1335 dialog.Dispose(); | |
1336 } | |
1337 } | |
1338 } | |
1339 | |
1340 private string MakeAddDataFileFailedMessage(List<Exception> exceptions) | |
1341 { | |
1342 StringBuilder sb = new StringBuilder(); | |
1343 sb.Append("errors occurred while adding the new data files: "); | |
1344 | |
1345 foreach (Exception ex in exceptions) | |
1346 { | |
1347 sb.Append("\n\t• "); | |
1348 sb.Append(ex.Message); | |
1349 } | |
1350 | |
1351 return sb.ToString(); | |
1320 } | 1352 } |
1321 } | 1353 } |
1322 } | 1354 } |