changed e.getCause to e when checking for exception instance