Avoid mangling traceback ANSI formatting.

This also attaches the traceback text to the NotebookError that gets raised if
exceptions are allowed.