Fix the broken exception handling