code: def to_dict(self):
          
          error_dict = {}
          for field in ('status', 'source', 'title', 'detail', 'id', 'code', 'links', 'meta'):
              if getattr(self, field, None):
                  error_dict.update({field: getattr(self, field)})
  
          return error_dict
docs: Return values of each fields of an jsonapi error