Skip to content

Commit cbec0d6

Browse files
committed
Improve error messages with helpful guidance
- Text editor sanity check errors now show possible causes (invalid syntax, malformed headers, indentation issues) - Validation errors now show common causes (invalid characters, name too long/empty, duplicate names) - Modification prevented error now shows step-by-step solution (how to change file permissions) - File overwrite dialog now shows filename and warns about recovery - All dialogs now use proper localization with _() - Added error icons to dialogs for better visibility
1 parent 9abf0c5 commit cbec0d6

3 files changed

Lines changed: 32 additions & 13 deletions

File tree

src/robotide/editor/customsourceeditor.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,11 @@ def on_save(self, event, filepath=None):
300300
return
301301
if filepath:
302302
if filepath != self.path and os.path.isfile(filepath):
303-
overwrite_msg = "You are about to overwrite an existing file\n" + \
304-
"Do you want to continue?"
305-
dlg = wx.MessageDialog(self, overwrite_msg, "Editor Writer",
303+
overwrite_msg = _("You are about to overwrite an existing file.\n\n") + \
304+
_("File: %s\n\n") % filepath + \
305+
_("The existing file will be replaced and cannot be recovered.\n\n") + \
306+
_("Do you want to continue?")
307+
dlg = wx.MessageDialog(self, overwrite_msg, _("Confirm Overwrite"),
306308
wx.YES_NO | wx.NO_DEFAULT | wx.ICON_EXCLAMATION)
307309
dlg.SetBackgroundColour(Colour(200, 222, 40))
308310
dlg.SetForegroundColour(Colour(7, 0, 70))

src/robotide/editor/texteditor.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -776,11 +776,16 @@ def _old_handle_sanity_check_failure(self):
776776
self._editor._mark_file_dirty()
777777
return False
778778
# TODO: use widgets.Dialog
779-
id = wx.MessageDialog(self._editor,
780-
'ERROR: Data sanity check failed!\n'
781-
'Reset changes?',
782-
'Can not apply changes from Txt Editor',
783-
style=wx.YES | wx.NO).ShowModal()
779+
msg = _('ERROR: Data sanity check failed!') + '\n\n' + \
780+
_('The text content could not be parsed correctly.') + '\n' + \
781+
_('This may be caused by:') + '\n' + \
782+
_(' - Invalid Robot Framework syntax') + '\n' + \
783+
_(' - Malformed table or section headers') + '\n' + \
784+
_(' - Incorrect indentation or spacing') + '\n\n' + \
785+
_('Reset changes?')
786+
id = wx.MessageDialog(self._editor, msg,
787+
_('Can not apply changes from Text Editor'),
788+
style=wx.YES | wx.NO | wx.ICON_ERROR).ShowModal()
784789
self._last_answer = id
785790
self._last_answer_time = time()
786791
if id == wx.ID_YES:
@@ -907,8 +912,12 @@ def _handle_sanity_check_failure(self, message):
907912
# self.source_editor._mark_file_dirty(True)
908913
return False
909914
dlg = RIDEDialog(title=_("Can not apply changes from Text Editor"),
910-
message=f"{_('ERROR: Data sanity check failed!')}\n{_('Error at line')}"
911-
f" {message[1]}:\n{message[0]}\n\n{_('Reset changes?')}",
915+
message=f"{_('ERROR: Data sanity check failed!')}\n\n"
916+
f"{_('Error at line')} {message[1]}:\n"
917+
f" {message[0]}\n\n"
918+
f"{_('This may be caused by invalid syntax or formatting.')}\n"
919+
f"{_('Check the line and fix the error, or reset changes.')}\n\n"
920+
f"{_('Reset changes?')}",
912921
style=wx.ICON_ERROR | wx.YES_NO)
913922
dlg.InheritAttributes()
914923
did = dlg.ShowModal()

src/robotide/ui/mainframe.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,23 @@ def _create_title(message):
216216

217217
@staticmethod
218218
def _show_validation_error(message):
219-
message_box = RIDEDialog(title=_('Validation Error'), message=message.message, style=wx.ICON_ERROR|wx.OK)
219+
error_msg = message.message
220+
help_text = "\n\n" + _("Common causes:") + "\n" + _(" - Invalid characters in name") + "\n" + _(" - Name too long or empty") + "\n" + _(" - Duplicate name already exists")
221+
message_box = RIDEDialog(title=_('Validation Error'),
222+
message=error_msg + help_text,
223+
style=wx.ICON_ERROR|wx.OK)
220224
message_box.ShowModal()
221225

222226
@staticmethod
223227
def _show_modification_prevented_error(message):
228+
filename = message.controller.datafile_controller.filename
224229
message_box = RIDEDialog(title=_("Modification prevented"),
225-
message=_("\"%s\" is read only") % message.controller.datafile_controller.filename,
230+
message=_("\"%s\" is read only.\n\n") % filename +
231+
_("To make changes:\n") +
232+
_(" 1. Close the file in RIDE\n") +
233+
_(" 2. Change file permissions in your file manager\n") +
234+
_(" 3. Reopen the file in RIDE"),
226235
style=wx.ICON_ERROR|wx.OK)
227-
# message_box.CenterOnParent()
228236
message_box.ShowModal()
229237

230238
def _init_ui(self):

0 commit comments

Comments
 (0)