cfpb / regulations-site

(DEPRECATED) Web interface for viewing U.S. federal regulations and other regulatory information
Other
28 stars 43 forks source link

Handle invalid SXS paragraphs with 404, not 500 #832

Closed chosak closed 7 years ago

chosak commented 7 years ago

This change wraps the MissingContentException that gets thrown due to invalid SXS label requests so that it raises an Http404 instead of causing a 500 error.

This can be tested by trying to manually access an invalid URL for a section for which no SXS analysis exists. These URLs should never be generated in a browser, but might be generated e.g. by URL hacking or by bots/crawlers.

An example URL that currently causes a problem for Reg E is:

http://localhost:8000/eregulations/partial/sxs/1005-31-a/2012-1728?from_version=2016-24506#1005-31-a

This raises a 500 because there's no 1005-31-a label in the SXSanalysis, unlike a valid section like:

http://localhost:8000/eregulations/partial/sxs/1005-31/2012-1728?from_version=2016-24506#1005-31