def set_hint_and_details(self, hint, details=None): ex.replace_context( self, ex.DefaultExceptionContext(hint=hint, details=details)) if hint is not None: self._attrs['H'] = hint if details is not None: self._attrs['D'] = details
def __init__(self, msg=None, *, hint=None, details=None, schema1=None, schema2=None, schema1_title=None, schema2_title=None, checksums1=None, checksums2=None): super().__init__(msg, hint=hint, details=details) if schema1 and schema2: err_ctx = DeltaExceptionSchemaContext(schema1, schema2, schema1_title=schema1_title, schema2_title=schema2_title, schema1_checksums=checksums1, schema2_checksums=checksums2) base_err.replace_context(self, err_ctx)
async def _execute_ddl(self, sql_text): try: if debug.flags.delta_execute: debug.header('Delta Script') debug.dump_code(sql_text, lexer='sql') await self.connection.execute(sql_text) except Exception as e: position = getattr(e, 'position', None) internal_position = getattr(e, 'internal_position', None) context = getattr(e, 'context', '') if context: pl_func_line = re.search( r'^PL/pgSQL function inline_code_block line (\d+).*', context, re.M) if pl_func_line: pl_func_line = int(pl_func_line.group(1)) else: pl_func_line = None point = None if position is not None: position = int(position) point = parser_context.SourcePoint( None, None, position) text = e.query if text is None: # Parse errors text = sql_text elif internal_position is not None: internal_position = int(internal_position) point = parser_context.SourcePoint( None, None, internal_position) text = e.internal_query elif pl_func_line: point = parser_context.SourcePoint( pl_func_line, None, None ) text = sql_text if point is not None: context = parser_context.ParserContext( 'query', text, start=point, end=point) exceptions.replace_context(e, context) raise
def __init__(self, driver_err, query_text, query_offset=0): super().__init__(driver_err.message) err_details = getattr(driver_err, 'details', None) try: position = err_details['position'] except KeyError: position = None else: try: position = int(position) - 1 except ValueError: position = None else: position -= query_offset ctx = QueryExceptionContext(query=query_text, position=position) replace_context(self, ctx)
def compile_ir_to_sql_tree(ir_expr: irast.Base, *, schema: s_schema.Schema, output_format: typing.Optional[OutputFormat] = None, ignore_shapes: bool = False, singleton_mode: bool = False) -> pgast.Base: try: # Transform to sql tree ctx_stack = context.CompilerContext() ctx = ctx_stack.current expr_is_stmt = isinstance(ir_expr, irast.Statement) if expr_is_stmt: views = ir_expr.views ctx.scope_map = ir_expr.scope_map ctx.scope_tree = ir_expr.scope_tree ir_expr = ir_expr.expr else: views = {} ctx.env = context.Environment(schema=schema, output_format=output_format, singleton_mode=singleton_mode, views=views) if ignore_shapes: ctx.expr_exposed = False qtree = dispatch.compile(ir_expr, ctx=ctx) except Exception as e: # pragma: no cover try: args = [e.args[0]] except (AttributeError, IndexError): args = [] err = errors.IRCompilerInternalError(*args) err_ctx = errors.IRCompilerErrorContext(tree=ir_expr) edgedb_error.replace_context(err, err_ctx) raise err from e return qtree
def __init__(self, msg=None, *, hint=None, details=None, delta=None): super().__init__(msg, hint=hint, details=details) self.delta = delta if self.delta is not None: base_err.replace_context( self, DeltaExceptionContext(delta=self.delta))
def set_source_context(self, context): ex.replace_context(self, context) if context.start is not None: self._attrs['P'] = str(context.start.pointer) self._attrs['p'] = str(context.end.pointer)