o
    lqi	                     @   sH   d Z ddlZddlZddlmZmZ ddlmZ ddlm	Z	 dd Z
dS )zf
This module provides general http handler functions for processing http responses from BCM services.
    N)compatutils)BceClientError)BceServerErrorc                 C   s   | j d tjjd krdS | j d tjjd krtd|  }|s1t| j|j	j
d}| j |_|tt|}t|}d|v rK|d durK|d }d}d|v r[|d dur[|d }|j	j
}d	|v rm|d	 durm|d	 }t|||d
}| j |_|)aH  If the body is not empty, convert it to a python object and set as the value of
    response.body. http_response is always closed if no error occurs.

    :param http_response: the http_response object returned by HTTPConnection.getresponse()
    :type http_response: httplib.HTTPResponse

    :param response: general response object which will be returned to the caller
    :type response: baidubce.BceResponse

    :return: false if http status code is 2xx, raise an error otherwise
    :rtype bool

    :raise baidubce.exception.BceClientError: if http status code is NOT 2xx
    d   Fs#   Can not handle 1xx http status code)
request_idmessageN	Exceptioncoder   )r
   r   )statushttpclientOKCONTINUEr   readr   reasonmetadataZbce_request_idstatus_codejsonloadsr   Zconvert_to_stringstr)http_responseresponsebodyZbseZ
error_dictr   r
   r    r   h/home/app/PaddleOCR-VL/.venv_paddleocr/lib/python3.10/site-packages/baidubce/services/bls/bls_handler.pyparse_error   s,   r   )__doc__http.clientr   r   Zbaidubcer   r   Zbaidubce.exceptionr   r   r   r   r   r   r   <module>   s   