changed throwing exception mechanism to preserve stack trace