Improve diagnostics for exceptions thrown during formatting.