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 1010from rich .console import Console
1111from rich .table import Table
1212
13- from wherobots .db import connect , connect_direct
13+ from wherobots .db import connect , connect_direct , errors
1414from wherobots .db .constants import DEFAULT_ENDPOINT , DEFAULT_SESSION_TYPE
1515from wherobots .db .connection import Connection
1616from wherobots .db .region import Region
@@ -103,8 +103,12 @@ def execute(conn: Connection, sql: str) -> pandas.DataFrame:
103103 cursor .execute (sql )
104104 return cursor .fetchall ()
105105
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(
116116 )
117117 resp .raise_for_status ()
118118 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
120128
121129 # At this point we've been redirected to /sql/session/{session_id}, which we'll need to keep polling until the
122130 # session is in READY state.
You can’t perform that action at this time.
0 commit comments