function rethrowCaughtError() {
    if (hasRethrowError) {
      var error = rethrowError;
      hasRethrowError = false;
      rethrowError = null;
      throw error;
    }
  }
During execution of guarded functions we will capture the first error which
we will rethrow to be handled by the top level error handler.