rework error object. Closes #239