code: def add_error(cls, queue_name, job, error, when=None, trace=None,
                                                          **additional_fields):
          
          if when is None:
              when = datetime.utcnow()
          when = str(when)
  
          fields = dict(
              queue_name=queue_name,
              job_model_repr=job.get_model_repr(),
              job_pk=job.pk.get(),
              identifier=getattr(job, '_cached_identifier', job.identifier.hget()),
              date_time=when,
              date=when[:10],
              time=when[11:],
              message=str(error),
          )
  
          try:
              # exception can be a class (should not, but just in case...)
              fields['type'] = error.__name__
          except AttributeError:
              # or excetion is an instance
              fields['type'] = error.__class__.__name__
  
          error_code = getattr(error, 'code', None)
          if error_code is not None:
              fields['code'] = error_code
  
          if trace:
              fields['traceback'] = trace
  
          error = cls(**fields)
  
          if additional_fields:
              error.set_fields(**additional_fields)
  
          return error
docs: Add a new error in redis.
          `job` is a job which generated the error
          `queue_name` is the name of the queue where the error arrived
          `error` is an exception, which can has a code (better if it is)
          `when` is the datetime of the error, utcnow will be used if not defined
          `trace` is the traceback generated by the exception, may be null
          The new created instance is returned, with additional_fields set for
          aubclasses.