public void HandleError([NotNull] Exception exception) { if (exception == null) { throw new ArgumentNullException("exception"); } GameLog.Server.General.Error(BuildErrorMessage(exception)); string header; string message; var gameDataException = exception as GameDataException; if (gameDataException != null) { header = _resourceManager.GetString("GAME_DATA_ERROR_HEADER"); message = _resourceManager.GetStringFormat( "GAME_DATA_ERROR_MESSAGE_FORMAT", gameDataException.Message, gameDataException.FileName); } else { header = _resourceManager.GetString("GENERIC_ERROR_HEADER"); message = _resourceManager.GetStringFormat( "GENERIC_ERROR_MESSAGE_FORMAT", exception.Message); } _dispatcherService.Invoke( (Action) (() => { var formattedTextConverter = new FormattedTextConverter(); var messageText = new TextBlock { TextWrapping = TextWrapping.Wrap }; BindingHelpers.SetInlines( messageText, (Inline[])formattedTextConverter.Convert(message)); MessageDialog.Show( header, messageText, MessageDialogButtons.Ok); var supremacyException = exception as SupremacyException; if (supremacyException == null) { ClientCommands.Exit.Execute(false); return; } switch (supremacyException.Action) { case SupremacyExceptionAction.Continue: break; case SupremacyExceptionAction.Exit: ClientCommands.Exit.Execute(false); break; default: case SupremacyExceptionAction.Undefined: case SupremacyExceptionAction.Disconnect: ClientCommands.EndGame.Execute(false); break; } })); }