throw exception if context is not set
make context a local var