[Rt-commit] rt branch, 4.0/report-ticketsql-errors, created. rt-4.0.11rc1-25-gbbbff09

Thomas Sibley trs at bestpractical.com
Thu Apr 4 20:02:47 EDT 2013


The branch, 4.0/report-ticketsql-errors has been created
        at  bbbff09492490ef1e723c0d610838cee92f3cb78 (commit)

- Log -----------------------------------------------------------------
commit bbbff09492490ef1e723c0d610838cee92f3cb78
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Apr 4 16:45:19 2013 -0700

    Report better errors when unable to parse or execute TicketSQL
    
    Tell the user that their query failed and provide the reason trimmed of
    any stack trace.  Additionally, record any unparseable query in the logs
    for the admin.
    
    Previously parse errors were silent to the user and simply didn't return
    any results.  Only the advanced query page reported errors.

diff --git a/lib/RT/Tickets_SQL.pm b/lib/RT/Tickets_SQL.pm
index 608862a..7d58242 100644
--- a/lib/RT/Tickets_SQL.pm
+++ b/lib/RT/Tickets_SQL.pm
@@ -292,8 +292,9 @@ sub FromSQL {
     $self->{_sql_query} = $query;
     eval { $self->_parser( $query ); };
     if ( $@ ) {
-        $RT::Logger->error( $@ );
-        return (0, $@);
+        my $error = "$@";
+        $RT::Logger->error("Couldn't parse << $query >>: $error");
+        return (0, $error);
     }
 
     # We only want to look at EffectiveId's (mostly) for these searches.
diff --git a/share/html/Search/Results.html b/share/html/Search/Results.html
index 13fa3c0..878c4f3 100644
--- a/share/html/Search/Results.html
+++ b/share/html/Search/Results.html
@@ -52,6 +52,11 @@
 
 % $m->callback( ARGSRef => \%ARGS, CallbackName => 'BeforeResults' );
 
+% unless ($ok) {
+%     $msg =~ s{ at .*? line .*}{}s;
+<p><&|/l_unsafe, "<i>".$m->interp->apply_escapes($msg, "h")."</i>" &>There was an error parsing your search query: [_1].  Your RT admin can find more information in the error logs.</&></p>
+% }
+
 <& /Elements/CollectionList, 
     Query => $Query,
     TotalFound => $ticketcount,

-----------------------------------------------------------------------


More information about the Rt-commit mailing list