only write exception if there is one