Allow state to be returned with an error
Merge branch 'feature-add-state-to-error'