check whether $ is defined, and throw an error on redis error