ktmud commented on a change in pull request #10274:
URL:
https://github.com/apache/incubator-superset/pull/10274#discussion_r454521047
##########
File path: superset/errors.py
##########
@@ -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_ERROR_CODES_MAPPING = {
+ SupersetErrorType.BACKEND_TIMEOUT_ERROR: [
+ {
+ "code": 1000,
+ "message": _("Error 1000 - The datasource is too large to query."),
+ },
+ {
+ "code": 1001,
+ "message": _("Error 1001 - The database is under an unusual
load."),
+ },
+ ]
+}
Review comment:
Yes, I agree error codes and possible root causes shouldn't be mixed
together as suggesting root causes and providing remedies are more of a
documentation issue rather than something the program cares about.
I've removed the `description` field in my example code, but other parts of
the code still feel like an improvement to me though. There really is no need
to have two separate entities for exception catching and messaging.
As for the mapping between symptoms and root causes, maybe we can extend the
`errors.json` file I suggested earlier and add a `causes` field?
```js
{
"issues": {
"DATASOURCE_TOO_LARGE": {
"code": 1001,
"title": "The database is too large to query",
"description": "It's likely your datasource has grown too large to run
the current query, and is timing out. You can resolve this by reducing the size
of your datasource or by modifying your query to only process a subset of your
data."
},
"DATASOURCE_OVERLOAD": {
"code": 1002,
// ....
},
},
"causes": {
"BACKEND_TIMEOUT_ERROR": ["DATASOURCE_TOO_LARGE", "DATASOURCE_OVERLOAD"],
}
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]