Adapting code about showing exceptions.