id summary reporter owner description type status priority milestone component version severity resolution keywords cc branch changelog apichanges internalchanges 12697 "QuerySyntaxError: Query filter requires field and constraints separated by a ""=""" Ryan J Ollos Ryan J Ollos "The traceback below appears in the logs when `[[TicketQuery(keywords~=firefox&chrome, format=table)]]`. See also #12286. I need to review this, but I think we settled on the `MacroError` pattern: {{{#!diff diff --git a/trac/ticket/query.py b/trac/ticket/query.py index 1f3fca98c..30d580b46 100644 --- a/trac/ticket/query.py +++ b/trac/ticket/query.py @@ -46,7 +46,7 @@ from trac.web.chrome import (INavigationContributor, Chrome, add_script_data, add_stylesheet, add_warning, web_context) from trac.wiki.api import IWikiSyntaxProvider -from trac.wiki.formatter import system_message +from trac.wiki.formatter import MacroError from trac.wiki.macros import WikiMacroBase @@ -1354,7 +1354,10 @@ class TicketQueryMacro(WikiMacroBase): query_string += '&' query_string += '&'.join('%s=%s' % item for item in kwargs.iteritems()) - query = Query.from_string(self.env, query_string) + try: + query = Query.from_string(self.env, query_string) + except QuerySyntaxError as e: + raise MacroError(e) if format in ('count', 'rawcount'): cnt = query.count(req) @@ -1370,8 +1373,7 @@ class TicketQueryMacro(WikiMacroBase): try: tickets = query.execute(req) except QueryValueError as e: - self.log.warning(e) - return system_message(_(""Error executing TicketQuery macro""), e) + raise MacroError(e) if format == 'table': data = query.template_data(formatter.context, tickets, diff --git a/trac/wiki/formatter.py b/trac/wiki/formatter.py index 7ca620540..9f7efc454 100644 --- a/trac/wiki/formatter.py +++ b/trac/wiki/formatter.py @@ -794,7 +794,8 @@ class Formatter(object): try: return macro.ensure_inline(macro.process(args)) except MacroError as e: - return system_message(e) + return system_message(_(""Macro %(name)s(%(args)s) failed"", + name=name, args=args), to_unicode(e)) except Exception as e: self.env.log.error('Macro %s(%s) failed:%s', name, args, exception_to_unicode(e, traceback=True)) }}} With the change, the error message would be: {{{#!html
Query filter requires field and constraints separated by a ""=""