Show error message instead of 500 page if search syntax causes error

Description

Right now, if your search errors on the backend, you just get a 500 page. It would be nicer to rescue those and show an error message instead, so it's easier for the user to try again.

Activity

Show:
Sarken
January 1, 2019, 9:23 AM
Edited

On the work search page, I entered "{momentum}" (no quotes) in the Title field and pressed search.

Results page at https://test.archiveofourown.org/works/search?utf8=✓&commit=Search&work_search%5Bquery%5D=&work_search%5Btitle%5D=%7Bmomentum%7D&work_search%5Bcreators%5D=&work_search%5Brevised_at%5D=&work_search%5Bcomplete%5D=&work_search%5Bcrossover%5D=&work_search%5Bsingle_chapter%5D=0&work_search%5Bword_count%5D=&work_search%5Blanguage_id%5D=&work_search%5Bfandom_names%5D=&work_search%5Brating_ids%5D=&work_search%5Bcharacter_names%5D=&work_search%5Brelationship_names%5D=&work_search%5Bfreeform_names%5D=&work_search%5Bhits%5D=&work_search%5Bkudos_count%5D=&work_search%5Bcomments_count%5D=&work_search%5Bbookmarks_count%5D=&work_search%5Bsort_column%5D=_score&work_search%5Bsort_direction%5D=desc had a red flash message saying, "Your search failed because of a syntax error. Please try again." and the search summary correctly summarized my search and the results:

Search Results
You searched for: Title: {momentum} sort by: best match descending
No results found. You may want to edit your search to make it less specific.

Looks good!

mumble
January 9, 2019, 5:40 PM
Edited

Entered “{‌{‌moo” (no quotes) on Production to make sure it produces an error 500 (it does); on Staging I get a results page at:

[https://test.archiveofourown.org/works/search?utf8=✓&work_search[query]={‌{moo|https://test.archiveofourown.org/works/search?utf8=%E2%9C%93&work_search%5Bquery%5D=%7B%7Bmoo]

with a red error message saying:

“Your search failed because of a syntax error. Please try again.”

and the page body:

Search Results

You searched for: {‌{moo sort by: best match descending

No results found. You may want to edit your search to make it less specific.

mumble
January 9, 2019, 5:43 PM

Did the same thing as above for ^^^hello, with identical results.

Looks good!

Lady Oscar
January 9, 2019, 6:14 PM

Confirmed!

DeployedToBeta

Assignee

Elz J

Reporter

Elz J

Roadmap

Search

Priority

Medium

Affects versions

Fix versions

Components

BackEnd

Difficulty

Medium

Epic Link

Milestone

Internal 0.9
Configure