Refactor exception wrapping