Am 07.12.2017 um 19:48 schrieb Chad:
Basically the short version is: exceptions should only be shown to users in the situation of *actual software errors*. They're the exception, not the norm. What we *should* do in such situation is log the error (at the ERROR/WARNING/etc level as appropriate) and then gracefully fall back.
I agree with the idea, but I'd like to point out that log-and-fall-back should *not* be the normal way to handle things, IMHO.
Let's take for example an invalid title. If a user supplied an invalid title, they should get a helpful error. There is no reason to even log this, really. This should be done by code that expects to handle user input, and can involve throwing and catching exceptions, or be handled some other way.
Code that does not expect raw user input usually SHOULD thrown an InvalidArgumentException if it gets invalid input, though! Something went wrong, so we should fail fast & safe!
We should however improve how we show exceptions to users. We have "nicer" handling for MWException than for other exceptions. I can think of no good reason for this distinction - can't we do the nicer handling for all exceptions?
The log-and-fall-back case should be quite rare, and be reserved for compatibility code - compatibility with old data, in particular. So perhaps the invalid title comes from the page or the pagelinks table - that's unexpected, but not impossible: someone may have fiddled with $wgLegalTitleChars, rendering once-valid titles invalid. So in that case, log-and-fall-back is the correct behavior.