fix erroneous exception handling