Skip to content

Commit

Permalink
Slight change to the build_error_result API to return dict.
Browse files Browse the repository at this point in the history
The dict is then wrapped with the Error class.
  • Loading branch information
coleifer committed Mar 16, 2021
1 parent a9e2b51 commit 6c899b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 4 additions & 4 deletions huey/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,8 @@ def _execute(self, task, timestamp):

if self.results and not isinstance(task, PeriodicTask):
if exception is not None:
error = self.build_error_result(task, exception)
self.put_result(task.id, error)
error_data = self.build_error_result(task, exception)
self.put_result(task.id, Error(error_data))
elif task_value is not None or self.store_none:
self.put_result(task.id, task_value)

Expand Down Expand Up @@ -453,12 +453,12 @@ def build_error_result(self, task, exception):
except AttributeError: # Seems to only happen on 3.4.
tb = '- unable to resolve traceback on Python 3.4 -'

return Error({
return {
'error': repr(exception),
'retries': task.retries,
'traceback': tb,
'task_id': task.id,
})
}

def _task_key(self, task_class, key):
return ':'.join((key, self._registry.task_to_string(task_class)))
Expand Down
3 changes: 1 addition & 2 deletions huey/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1293,8 +1293,7 @@ def get_huey(self):
class CustomError(MemoryHuey):
def build_error_result(self, task, exc):
err = super(CustomError, self).build_error_result(task, exc)
err.metadata['name'] = task.name
err.metadata['args'] = task.args
err.update(name=task.name, args=task.args)
return err
return CustomError(utc=False)

Expand Down

0 comments on commit 6c899b4

Please sign in to comment.