32
32
from .dss .utils import DSSInfoMessages , Enum
33
33
from .dss .workspace import DSSWorkspace
34
34
import os .path as osp
35
- from .utils import DataikuException , dku_basestring_type
35
+ from .utils import dku_basestring_type , handle_http_exception
36
36
from .govern_client import GovernClient
37
37
38
38
@@ -1503,21 +1503,14 @@ def _perform_http(self, method, path, params=None, body=None, stream=False, file
1503
1503
if raw_body is not None :
1504
1504
body = raw_body
1505
1505
1506
- try :
1507
- http_res = self ._session .request (
1508
- method , "%s/dip/publicapi%s" % (self .host , path ),
1509
- params = params , data = body ,
1510
- files = files ,
1511
- stream = stream ,
1512
- headers = headers )
1513
- http_res .raise_for_status ()
1514
- return http_res
1515
- except exceptions .HTTPError :
1516
- try :
1517
- ex = http_res .json ()
1518
- except ValueError :
1519
- ex = {"message" : http_res .text }
1520
- raise DataikuException ("%s: %s" % (ex .get ("errorType" , "Unknown error" ), ex .get ("detailedMessage" , ex .get ("message" , "No message" ))))
1506
+ http_res = self ._session .request (
1507
+ method , "%s/dip/publicapi%s" % (self .host , path ),
1508
+ params = params , data = body ,
1509
+ files = files ,
1510
+ stream = stream ,
1511
+ headers = headers )
1512
+ handle_http_exception (http_res )
1513
+ return http_res
1521
1514
1522
1515
def _perform_empty (self , method , path , params = None , body = None , files = None , raw_body = None ):
1523
1516
self ._perform_http (method , path , params = params , body = body , files = files , stream = False , raw_body = raw_body )
@@ -1532,15 +1525,12 @@ def _perform_raw(self, method, path, params=None, body=None,files=None, raw_body
1532
1525
return self ._perform_http (method , path , params = params , body = body , files = files , stream = True , raw_body = raw_body )
1533
1526
1534
1527
def _perform_json_upload (self , method , path , name , f ):
1535
- try :
1536
- http_res = self ._session .request (
1537
- method , "%s/dip/publicapi%s" % (self .host , path ),
1538
- files = {'file' : (name , f , {'Expires' : '0' })} )
1539
- http_res .raise_for_status ()
1540
- return http_res
1541
- except exceptions .HTTPError :
1542
- ex = http_res .json ()
1543
- raise DataikuException ("%s: %s" % (ex .get ("errorType" , "Unknown error" ), ex .get ("message" , "No message" )))
1528
+ http_res = self ._session .request (
1529
+ method , "%s/dip/publicapi%s" % (self .host , path ),
1530
+ files = {'file' : (name , f , {'Expires' : '0' })} )
1531
+
1532
+ handle_http_exception (http_res )
1533
+ return http_res
1544
1534
1545
1535
########################################################
1546
1536
# Discussions
0 commit comments