mozilla/kitsune — pull request #1229 by mythmon (2013-03-25 22:09:48+00:00)
Title: [Bug 850215] Safe email translation.

I made a decorator that calls a function, and catches any errors that
might be localization issues. If one of these types of exceptions is
raised, it logs the request and sets the locale to English and tries
again. Then I found all the places where @willkg's `uselocale` context
manager was being used and converted it to a function that used this
decorator. In my testing this makes emails robust to localization
errors.

I tried to make this a modification to the context manager originally,
but to run the wrapped code again would require ugly bad horrible
bytecode hacks. So I decided better not do that. Luckily, this was is
generic enough that it might be reusable for web traffic too. I didn't
look into this very much.

I tried to log these errors in a way that will make them easy to work
on. I am assuming that we have Sentry/Raven configured to automatically
add stack traces. If this assumption is wrong, we will see that when it
goes to stage, and can add the stack trace into the error message.

r?