def check_error(response, expect_status=<NUM_LIT:200>):
json = None<EOL>try:<EOL><INDENT>json = response.json()<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT>if (response.status_code != expect_status or<EOL>response.status_code == <NUM_LIT> or<EOL>'<STR_LIT:error>' in json):<EOL><INDENT>if json:<EOL><INDENT>error = json['<STR_LIT:error>']<EOL>raise YoukuError(error['<STR_LIT:code>'], error['<STR_LIT:type>'],<EOL>error['<STR_LIT:description>'], response.status_code)<EOL><DEDENT>else:<EOL><INDENT>error = parse_qs(response.text)<EOL>raise YoukuError(error.get('<STR_LIT:code>', [None])[<NUM_LIT:0>],<EOL>error.get('<STR_LIT:type>', [None])[<NUM_LIT:0>],<EOL>error.get('<STR_LIT:description>', [None])[<NUM_LIT:0>],<EOL>response.status_code)<EOL><DEDENT><DEDENT>
Youku error should return in json form, like:
HTTP 400
{
    "error":{
        "code":120010223,
        "type":"UploadsException",
        "description":"Expired upload token"
    }
}

But error also maybe in response url params or response booy.

Content-Type maybe application/json or text/plain, so
don't relay on it.

Args:
    expect_status: normally is 200 or 201