well, even using preg_match won't change the fact that the response is invalid JSON in the error case, which means that json_decode will do weird stuff