send an error JSON object response on error