Skip to content

Commit

Permalink
fix when fails when catch errors
Browse files Browse the repository at this point in the history
  • Loading branch information
daimor committed Apr 12, 2023
1 parent ae5148f commit 149d63a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions irissqlcli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from cli_helpers.tabular_output import TabularOutputFormatter
from cli_helpers.tabular_output.preprocessors import align_decimals, format_numbers
from cli_helpers.utils import strip_ansi
from intersystems_iris.dbapi._DBAPI import OperationalError
from intersystems_iris.dbapi._DBAPI import OperationalError, DatabaseError
from prompt_toolkit.completion import DynamicCompleter, ThreadedCompleter
from prompt_toolkit.document import Document
from prompt_toolkit.enums import DEFAULT_BUFFER, EditingMode
Expand Down Expand Up @@ -418,12 +418,12 @@ def execute_command(self, text, handle_closed_connection=True):
click.secho("cancelled query", err=True, fg="red")
except NotImplementedError:
click.secho("Not Yet Implemented.", fg="yellow")
except OperationalError as e:
except DatabaseError as e:
logger.error("sql: %r, error: %r", text, e)
logger.error("traceback: %r", traceback.format_exc())
click.secho(str(e), err=True, fg="red")
if handle_closed_connection:
self._handle_server_closed_connection(text)
# if handle_closed_connection:
# self._handle_server_closed_connection(text)
except (IRISSQLCliQuitError, EOFError) as e:
raise
except Exception as e:
Expand Down Expand Up @@ -899,6 +899,7 @@ def cli(
logfile=logfile,
irissqlclirc=irissqlclirc,
auto_vertical_output=auto_vertical_output,
warn=warn,
)

if cert:
Expand Down
2 changes: 1 addition & 1 deletion irissqlcli/sqlexecute.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def run(
except special.CommandNotFound:
yield self.execute_normal_sql(sql) + (sql, True, False)

except dbapi.DatabaseError as e:
except dbapi.OperationalError as e:
_logger.error("sql: %r, error: %r", sql, e)
_logger.error("traceback: %r", traceback.format_exc())

Expand Down

0 comments on commit 149d63a

Please sign in to comment.