MCPcopy Index your code
hub / github.com/marimo-team/marimo / is_sql_parse_error

Function is_sql_parse_error

marimo/_sql/error_utils.py:53–102  ·  view source on GitHub ↗

Check if the exception is a SQL parsing error.

(exception: BaseException)

Source from the content-addressed store, hash-verified

51
52
53def is_sql_parse_error(exception: BaseException) -> bool:
54 """Check if the exception is a SQL parsing error."""
55 # Check for DuckDB exceptions first (most common)
56 if DependencyManager.duckdb.imported():
57 try:
58 import duckdb
59
60 # Errors are general enough to capture all meaningful SQL issues.
61 # NB. Errors like Binder/CatalogException are under ProgrammingError.
62 # The definitions can be found here:
63 # https://github.com/duckdb/duckdb-python/blob/0ee500cfa35fc07bf81ed02e8ab6984ea1f665fd/duckdb/__init__.pyi#L82
64 if isinstance(
65 exception,
66 (
67 duckdb.ParserException,
68 duckdb.ProgrammingError,
69 duckdb.IOException,
70 duckdb.OperationalError,
71 duckdb.IntegrityError,
72 duckdb.DataError,
73 ),
74 ):
75 return True
76 except ImportError:
77 pass
78
79 # Check for SQLGlot exceptions
80 if DependencyManager.sqlglot.imported():
81 try:
82 from sqlglot.errors import ParseError
83
84 # Definitions can be found here:
85 # https://sqlglot.com/sqlglot/errors.html
86 if isinstance(exception, ParseError):
87 return True
88 except ImportError:
89 pass
90
91 if DependencyManager.sqlalchemy.imported():
92 try:
93 from sqlalchemy.exc import ProgrammingError, SQLAlchemyError
94
95 # Definitions can be found here:
96 # https://docs.sqlalchemy.org/en/20/core/exceptions.html
97 if isinstance(exception, (SQLAlchemyError, ProgrammingError)):
98 return True
99 except ImportError:
100 pass
101
102 return isinstance(exception, MarimoSQLException)
103
104
105def _extract_sql_position(

Calls 1

importedMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…