B #ak@sddlZddlZddlmZmZmZmZeeZ dddZ Gddde Z Gdd d e Z Gd d d e ZGd d d e ZGddde ZGddde ZGddde ZerddlZddlmZGddde ZdS)N)CallableAnyOptional TYPE_CHECKINGc Os`t\}}}d||j|}||f||}y||Wntk rZ||_|YnXdS)a*Raise exception with a specified traceback. This MUST be called inside a "except" clause. :param Exception exception: Error type to be raised. :param str message: Message to include with error, empty by default. :param args: Any additional args to be included with exception. z {}, {}: {}N)sysexc_infoformat__name__with_tracebackAttributeError __traceback__) exceptionmessageargskwargsexc_type exc_value exc_tracebackexc_msgerrorr8/tmp/pip-target-jgxl_w8r/lib/python/msrest/exceptions.pyraise_with_traceback$s rcs"eZdZdZdfdd ZZS)ClientExceptionzBase exception for all Client Runtime exceptions. :param str message: Description of exception. :param Exception inner_exception: Nested exception (optional). Ncs,||_t|tt|j|f||dS)N)inner_exception_LOGGERdebugsuperr__init__)selfrrrr) __class__rrr@s zClientException.__init__)N)r __module__ __qualname____doc__r __classcell__rr)r!rr9src@seZdZdZdS)SerializationErrorz*Error raised during request serialization.N)r r"r#r$rrrrr&Gsr&c@seZdZdZdS)DeserializationErrorz-Error raised during response deserialization.N)r r"r#r$rrrrr'Lsr'c@seZdZdZdS)TokenExpiredErrorz$OAuth token expired, request failed.N)r r"r#r$rrrrr(Qsr(csLeZdZdZdddddddd d d d d dd ZeddZfddZZS)ValidationErrorzRequest parameter validation failed. :param str rule: Validation rule. :param str target: Target value for the rule. :param str value: Value that was invalid. z#must have length greater than {!r}.z must have length less than {!r}.zmust be greater than {!r}.zmust be less than {!r}.z&must be equal to or greater than {!r}.z#must be equal to or less than {!r}.z!must contain at least {!r} items.z must contain at most {!r} items.z,must conform to the following pattern: {!r}.zmust contain only unique items.zmust be a multiple of {!r}.zcan not be None.zmust be of type {!r}) Z min_length max_lengthZ minimum_exZ maximum_exZminimummaximumZ min_itemsZ max_itemspatternuniquemultiplerequiredtypecCs0|dkr&|dr&|d}d|}||S)Nr0{z{}z dict[str, {}]) startswithstripr )rulereasonvalueZ internal_typerrr_format_messagens  zValidationError._format_messagecsR||_||_d|}|j|d}|||||7}tt|j|f||dS)NzParameter {!r} z&failed to meet validation requirement.) r4targetr _messagesgetr7rr)r)r r4r8r6rrrr5)r!rrrus zValidationError.__init__) r r"r#r$r9 staticmethodr7rr%rr)r!rr)Vs  r)c@seZdZdZdS)ClientRequestErrorzClient request failed.N)r r"r#r$rrrrr<sr<c@seZdZdZdS)AuthenticationErrorz&Client request failed to authenticate.N)r r"r#r$rrrrr=sr=) Deserializercs.eZdZdZdZddZdfdd ZZS) HttpOperationErroraClient request failed due to server-specified HTTP operation error. Attempts to deserialize response into specific error object. :param Deserializer deserialize: Deserializer with data on custom error objects. :param requests.Response response: Server response :param str resp_type: Objects type to deserialize response. :param args: Additional args to pass to exception object. :ivar Model error: Deserialized error model. z Unknown errorcCs t|jS)N)strr)r rrr__str__szHttpOperationError.__str__Nc s~d|_|j|_t|dr"|j|_n||_yr|r||||_|jdkrR|j||_yd|jjj|jjj|_Wn&t k r|jjr|jj|_YnXWnt t t fk rYnX|jr|j|jkrLy | Wnft k rYn`t k r<}z2|js ||_|j|jkr,d}||j|_Wdd}~XYnX|jsL||_|jdk s\ttt|j|j|jf||dS)Ninternal_responsez({}) {}z.Operation returned an invalid status code {!r})r_DEFAULT_MESSAGErhasattrrCresponseZ dependenciesr coder r'KeyErrorraise_for_status Exceptionr5AssertionErrorrr@r)r Z deserializerFZ resp_typerrerrmsg)r!rrrsF       zHttpOperationError.__init__)N)r r"r#r$rDrBrr%rr)r!rr@s r@)r)loggingrtypingrrrr getLoggerr rrrJrr&r'r(r)r<r=requestsZ serializationr?r@rrrrs  *