Skip to content

Commit

Permalink
Merge pull request #1695 from RogerHaase/1687-macro-traceback
Browse files Browse the repository at this point in the history
cleanup macros with editing errors should not log tracebacks #1687
  • Loading branch information
RogerHaase authored May 27, 2024
2 parents f7e64dd + 006ade5 commit 3dd24c9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/moin/macros/Date.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def parse_time(self, args):
Parse a time specification argument for usage by Date and DateTime macro.
Not all ISO 8601 format variations are accepted as input.
:param args: float/int UNIX timestamp or null or ISO 8601 formatted date time:
:param args: float/int UNIX timestamp or None or ISO 8601 formatted date time:
YYYY-MM-DDTHH:MM:SS (plus optional Z or z for UTC, or +/-HHMM) or
YYYY-MM-DD HH:MM:SS (same as above but replacing T separator with " ")
:returns: UNIX timestamp (UTC) or raises one of AttributeError, OSError, AssertionError, ValueError, OverflowError
Expand Down Expand Up @@ -70,5 +70,5 @@ def macro(self, content, arguments, page_url, alternative):
tm = self.parse_time(tm)
return show_time.format_date(tm)
except (AttributeError, OSError, AssertionError, ValueError, OverflowError):
err_msg = _("Invalid input parameter: null, float, int, or ISO 8601 formats are accepted.")
err_msg = _("Invalid input parameter: None, float, int, or ISO 8601 formats are accepted.")
return fail_message(err_msg, alternative)
2 changes: 1 addition & 1 deletion src/moin/macros/DateTime.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ def macro(self, content, arguments, page_url, alternative):
tm = self.parse_time(tm)
return show_time.format_date_time(tm)
except (AttributeError, OSError, AssertionError, ValueError, OverflowError):
err_msg = _("Invalid input parameter: null, float, int, or ISO 8601 formats are accepted.")
err_msg = _("Invalid input parameter: None, float, int, or ISO 8601 formats are accepted.")
return fail_message(err_msg, alternative)
5 changes: 2 additions & 3 deletions src/moin/macros/FontAwesome.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@

class Macro(MacroInlineBase):
def macro(self, content, arguments, page_url, alternative):
args = arguments[0] if arguments else ""
if not args:
if not arguments:
err_msg = _("Missing font name, syntax is <<FontAwesome(name,color,size)>>")
return fail_message(err_msg, alternative)

args = args.split(",")
args = arguments[0].split(",")
fonts = args[0].split()
color = args[1].strip() if len(args) > 1 else ""
size = args[2].strip() if len(args) > 2 else ""
Expand Down
5 changes: 1 addition & 4 deletions src/moin/macros/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,7 @@ def fail_message(msg, alternative, severity="error"):
:returns: formatted text of macro, error message
"""
if severity not in "attention caution danger error hint important note tip".split():
severity = "error"
msg = (
_("Invalid severity, must be one of: ") + "attention, caution, danger, error, hint, important, note, or tip"
)
raise ValueError

altern = html.p(children=[html.strong(children=[alternative])])
message = html.p(children=[msg])
Expand Down

0 comments on commit 3dd24c9

Please sign in to comment.