feat: invalid DB name error messages (MySQL/Postgres/Redshift) (#14146)

* initial DB custom errors for mysql

* added redshift and postgres
This commit is contained in:
AAfghahi
2021-04-15 11:02:47 -04:00
committed by GitHub
parent 8ef572a412
commit eadff5f41e
9 changed files with 147 additions and 16 deletions

View File

@@ -238,7 +238,10 @@ class TestPostgresDbEngineSpec(TestDbEngineSpec):
)
]
msg = 'psql: error: could not translate host name "locahost" to address: nodename nor servname provided, or not known'
msg = (
'psql: error: could not translate host name "locahost" to address: '
"nodename nor servname provided, or not known"
)
result = PostgresEngineSpec.extract_errors(Exception(msg))
assert result == [
SupersetError(
@@ -250,7 +253,8 @@ class TestPostgresDbEngineSpec(TestDbEngineSpec):
"issue_codes": [
{
"code": 1007,
"message": "Issue 1007 - The hostname provided can't be resolved.",
"message": "Issue 1007 - The hostname provided "
"can't be resolved.",
}
],
},
@@ -303,7 +307,8 @@ psql: error: could not connect to server: Operation timed out
"issue_codes": [
{
"code": 1009,
"message": "Issue 1009 - The host might be down, and can't be reached on the provided port.",
"message": "Issue 1009 - The host might be down, "
"and can't be reached on the provided port.",
}
],
},
@@ -332,7 +337,8 @@ psql: error: could not connect to server: Operation timed out
"issue_codes": [
{
"code": 1009,
"message": "Issue 1009 - The host might be down, and can't be reached on the provided port.",
"message": "Issue 1009 - The host might be down, "
"and can't be reached on the provided port.",
}
],
},
@@ -360,3 +366,24 @@ psql: error: could not connect to server: Operation timed out
},
)
]
msg = 'database "badDB" does not exist'
result = PostgresEngineSpec.extract_errors(Exception(msg))
assert result == [
SupersetError(
error_type=SupersetErrorType.TEST_CONNECTION_UNKNOWN_DATABASE_ERROR,
message='We were unable to connect to your database named "badDB".'
" Please verify your database name and try again.",
level=ErrorLevel.ERROR,
extra={
"engine_name": "PostgreSQL",
"issue_codes": [
{
"code": 10015,
"message": "Issue 1015 - Either the database is "
"spelled incorrectly or does not exist.",
}
],
},
)
]