A handler returning controlled output prevents crashes and information leaks (CWE-391) — the framework default exposes stack traces, writing the exception to the response leaks internals to the user, and blind retries can loop forever or mask a real fault.
Official docs