Fix exception rethrows

The previous way of rethrowing the exceptions would destroy the stacktrace information associated with them.