File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -306,17 +306,20 @@ def create_repo(
306306 headers = {"authorization" : "Bearer {}" .format (token )},
307307 json = json ,
308308 )
309- if exist_ok and r .status_code == 409 :
310- d = r .json ()
311- return d ["url" ]
312309
313310 try :
314311 r .raise_for_status ()
315- except HTTPError as e :
316- if r .json ():
317- if "error" in r .json ():
318- raise HTTPError ("{} - {}" .format (e , r .json ()["error" ]))
319- raise e
312+ except HTTPError as err :
313+ if not (exist_ok and err .response .status_code == 409 ):
314+ try :
315+ additional_info = r .json ().get ("error" , None )
316+ if additional_info :
317+ new_err = f"{ err .args [0 ]} - { additional_info } "
318+ err .args = (new_err ,) + err .args [1 :]
319+ except ValueError :
320+ pass
321+
322+ raise err
320323
321324 d = r .json ()
322325 return d ["url" ]
You can’t perform that action at this time.
0 commit comments