mirror of
https://github.com/apache/superset.git
synced 2026-04-25 02:55:07 +00:00
feat: convert backend chart errors to the new error type (#9753)
This commit is contained in:
@@ -34,6 +34,7 @@ from typing import (
|
||||
Union,
|
||||
)
|
||||
|
||||
import dataclasses
|
||||
import pandas as pd
|
||||
import sqlparse
|
||||
from flask import g
|
||||
@@ -51,6 +52,7 @@ from sqlalchemy.types import TypeEngine
|
||||
from wtforms.form import Form
|
||||
|
||||
from superset import app, sql_parse
|
||||
from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
|
||||
from superset.models.sql_lab import Query
|
||||
from superset.utils import core as utils
|
||||
|
||||
@@ -568,6 +570,19 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
|
||||
"""Extract error message for queries"""
|
||||
return utils.error_msg_from_exception(ex)
|
||||
|
||||
@classmethod
|
||||
def extract_errors(cls, ex: Exception) -> List[Dict[str, Any]]:
|
||||
return [
|
||||
dataclasses.asdict(
|
||||
SupersetError(
|
||||
error_type=SupersetErrorType.GENERIC_DB_ENGINE_ERROR,
|
||||
message=cls.extract_error_message(ex),
|
||||
level=ErrorLevel.ERROR,
|
||||
extra={"engine": cls.engine},
|
||||
)
|
||||
)
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def adjust_database_uri(cls, uri: URL, selected_schema: Optional[str]) -> None:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user