File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change 10
10
from rich .console import Console
11
11
from rich .table import Table
12
12
13
- from wherobots .db import connect , connect_direct
13
+ from wherobots .db import connect , connect_direct , errors
14
14
from wherobots .db .constants import DEFAULT_ENDPOINT , DEFAULT_SESSION_TYPE
15
15
from wherobots .db .connection import Connection
16
16
from wherobots .db .region import Region
@@ -103,8 +103,12 @@ def execute(conn: Connection, sql: str) -> pandas.DataFrame:
103
103
cursor .execute (sql )
104
104
return cursor .fetchall ()
105
105
106
- with conn_func () as conn :
107
- with concurrent .futures .ThreadPoolExecutor () as pool :
108
- futures = [pool .submit (execute , conn , s ) for s in args .sql ]
109
- for future in concurrent .futures .as_completed (futures ):
110
- render (future .result ())
106
+ try :
107
+ with conn_func () as conn :
108
+ with concurrent .futures .ThreadPoolExecutor () as pool :
109
+ futures = [pool .submit (execute , conn , s ) for s in args .sql ]
110
+ for future in concurrent .futures .as_completed (futures ):
111
+ render (future .result ())
112
+ except errors .Error as e :
113
+ sys .stderr .write (f"\n { e } \n " )
114
+ sys .exit (1 )
Original file line number Diff line number Diff line change @@ -116,7 +116,15 @@ def connect(
116
116
)
117
117
resp .raise_for_status ()
118
118
except requests .HTTPError as e :
119
- raise InterfaceError ("Failed to create SQL session!" , e )
119
+ details = str (e )
120
+ try :
121
+ info = e .response .json ()
122
+ errors = info .get ("errors" , [])
123
+ if errors and isinstance (errors , list ):
124
+ details = f"{ errors [0 ]['message' ]} : { errors [0 ]['details' ]} "
125
+ except requests .JSONDecodeError :
126
+ pass
127
+ raise InterfaceError (f"Failed to create SQL session: { details } " ) from e
120
128
121
129
# At this point we've been redirected to /sql/session/{session_id}, which we'll need to keep polling until the
122
130
# session is in READY state.
You can’t perform that action at this time.
0 commit comments