Return errors as an error object. Closes #1