Skip to content

Commit

Permalink
Chdb python will raise ChdbError intead of general Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-Robbins committed Jan 10, 2024
1 parent b0665c9 commit c2dbe78
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion chdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
import os


class ChdbError(Exception):
"""Base class for exceptions in this module."""


_arrow_format = set({"dataframe", "arrowtable"})
_process_result_format_funs = {
"dataframe": lambda x: to_df(x),
Expand Down Expand Up @@ -71,5 +75,9 @@ def query(sql, output_format="CSV", path="", udf_path=""):
output_format = "Arrow"
res = _chdb.query(sql, output_format, path=path, udf_path=g_udf_path)
if res.has_error():
raise Exception(res.error_message())
raise ChdbError(res.error_message())
return result_func(res)


__all__ = ["ChdbError", "query", "chdb_version",
"engine_version", "to_df", "to_arrowTable"]

0 comments on commit c2dbe78

Please sign in to comment.