Closed Molrn closed 3 months ago
Chat UI works weird when it executes a SQL with an error
In my opinion this is the most critical issue of this bug. quick fix: override the connect_to_xxxx function of VannaBase like this:
class MyVanna(VannaBase):
def connect_to_xxxxxx(self):
super().connect_to_xxxx()
run_sql_function = self.run_sql
def run_sql_with_exception(sql: str) -> DataFrame:
try:
return run_sql_function(sql)
except ValidationError as e:
raise Exception(e)
self.run_sql = run_sql_with_exception
Description
The exceptions defined in vanna.exceptions can not be catched with a
try: ... except Exception as e:
.Reproduction
Explanation
Vanna exceptions are all derived from the class
BaseException
instead of the classException
.Therefore, they cannot be catched with
try: ... except Exception as e:
(BaseException Documentation).Solution
Define Exception as the parent class of all Vanna Exceptions instead of BaseException.
Alternative solution
It would be cleaner to have
and to only use a
try: ... except VannaError as e:
block when necessary, but this is not the focus of this PR.