Improve error object usage