Properly raise error at end