Add check for error object