feat: update timeout error UX (#10274)

This commit is contained in:
Erik Ritter
2020-07-20 15:32:17 -07:00
committed by GitHub
parent d92cb66f60
commit 5fa4680447
29 changed files with 557 additions and 65 deletions

View File

@@ -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})