mirror of
https://github.com/apache/superset.git
synced 2026-04-24 10:35:01 +00:00
feat: update timeout error UX (#10274)
This commit is contained in:
@@ -19,6 +19,7 @@ from enum import Enum
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from dataclasses import dataclass
|
||||
from flask_babel import gettext as _
|
||||
|
||||
|
||||
class SupersetErrorType(str, Enum):
|
||||
@@ -46,6 +47,23 @@ class SupersetErrorType(str, Enum):
|
||||
DATASOURCE_SECURITY_ACCESS_ERROR = "DATASOURCE_SECURITY_ACCESS_ERROR"
|
||||
MISSING_OWNERSHIP_ERROR = "MISSING_OWNERSHIP_ERROR"
|
||||
|
||||
# Other errors
|
||||
BACKEND_TIMEOUT_ERROR = "BACKEND_TIMEOUT_ERROR"
|
||||
|
||||
|
||||
ERROR_TYPES_TO_ISSUE_CODES_MAPPING = {
|
||||
SupersetErrorType.BACKEND_TIMEOUT_ERROR: [
|
||||
{
|
||||
"code": 1000,
|
||||
"message": _("Issue 1000 - The datasource is too large to query."),
|
||||
},
|
||||
{
|
||||
"code": 1001,
|
||||
"message": _("Issue 1001 - The database is under an unusual load."),
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
class ErrorLevel(str, Enum):
|
||||
"""
|
||||
@@ -69,3 +87,13 @@ class SupersetError:
|
||||
error_type: SupersetErrorType
|
||||
level: ErrorLevel
|
||||
extra: Optional[Dict[str, Any]] = None
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
"""
|
||||
Mutates the extra params with user facing error codes that map to backend
|
||||
errors.
|
||||
"""
|
||||
issue_codes = ERROR_TYPES_TO_ISSUE_CODES_MAPPING.get(self.error_type)
|
||||
if issue_codes:
|
||||
self.extra = self.extra or {}
|
||||
self.extra.update({"issue_codes": issue_codes})
|
||||
|
||||
Reference in New Issue
Block a user