Simplified error display dialog

This commit is contained in:
Daniel Schick 2024-09-10 18:06:28 +02:00
parent c375b9f553
commit 38563d5b38

View File

@ -337,7 +337,7 @@ namespace BreCalClient
{ {
this.Dispatcher.Invoke(new Action(() => this.Dispatcher.Invoke(new Action(() =>
{ {
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); ShowErrorDialog(ex.Message, "Error saving user information");
})); }));
} }
} }
@ -1064,6 +1064,7 @@ namespace BreCalClient
// Error calling ShipcallUpdate: {\"message\": \"PUT Requests for shipcalls can only be issued by an assigned AGENCY or BSMD users // Error calling ShipcallUpdate: {\"message\": \"PUT Requests for shipcalls can only be issued by an assigned AGENCY or BSMD users
// (if the special-flag is enabled). Assigned Agency: ShipcallParticipantMap(id=628, shipcall_id=115, participant_id=10, // (if the special-flag is enabled). Assigned Agency: ShipcallParticipantMap(id=628, shipcall_id=115, participant_id=10,
// type=8, created=datetime.datetime(2024, 8, 28, 15, 13, 14), modified=None) with Flags: 42\"} // type=8, created=datetime.datetime(2024, 8, 28, 15, 13, 14), modified=None) with Flags: 42\"}
Match m = Regex.Match(message, "\\{(.*)\\}"); Match m = Regex.Match(message, "\\{(.*)\\}");
if ((m != null) && m.Success) if ((m != null) && m.Success)
{ {
@ -1072,21 +1073,15 @@ namespace BreCalClient
dynamic? msg = JsonConvert.DeserializeObject(m.Value); dynamic? msg = JsonConvert.DeserializeObject(m.Value);
if (msg != null) if (msg != null)
{ {
if (msg.message != null) if (msg.error_field != null)
{ {
caption = $"{caption}: {msg.message}"; caption = $"{caption}: {msg.error_field}";
} }
if((msg.errors != null) && msg.errors.Count > 0) if(msg.error_description != null)
{ {
message = ""; message = msg.error_description;
foreach(string error in msg.errors) }
{
message += error;
message += Environment.NewLine;
}
}
} }
} }
catch (Exception) { } catch (Exception) { }