sqlmesh.cli
1import typing as t 2from functools import wraps 3 4import click 5from sqlglot.errors import SqlglotError 6 7from sqlmesh.utils.concurrency import NodeExecutionFailedError 8from sqlmesh.utils.errors import SQLMeshError 9 10DECORATOR_RETURN_TYPE = t.TypeVar("DECORATOR_RETURN_TYPE") 11 12 13def error_handler( 14 func: t.Callable[..., DECORATOR_RETURN_TYPE] 15) -> t.Callable[..., DECORATOR_RETURN_TYPE]: 16 @wraps(func) 17 def wrapper(*args: t.Any, **kwargs: t.Any) -> DECORATOR_RETURN_TYPE: 18 try: 19 return func(*args, **kwargs) 20 except NodeExecutionFailedError as ex: 21 cause = ex.__cause__ 22 raise click.ClickException(f"Failed processing {ex.node}. {cause}") 23 except (SQLMeshError, SqlglotError, ValueError) as ex: 24 raise click.ClickException(str(ex)) 25 26 return wrapper
def
error_handler( func: Callable[..., ~DECORATOR_RETURN_TYPE]) -> Callable[..., ~DECORATOR_RETURN_TYPE]:
14def error_handler( 15 func: t.Callable[..., DECORATOR_RETURN_TYPE] 16) -> t.Callable[..., DECORATOR_RETURN_TYPE]: 17 @wraps(func) 18 def wrapper(*args: t.Any, **kwargs: t.Any) -> DECORATOR_RETURN_TYPE: 19 try: 20 return func(*args, **kwargs) 21 except NodeExecutionFailedError as ex: 22 cause = ex.__cause__ 23 raise click.ClickException(f"Failed processing {ex.node}. {cause}") 24 except (SQLMeshError, SqlglotError, ValueError) as ex: 25 raise click.ClickException(str(ex)) 26 27 return wrapper