1
0
Fork 0
mirror of synced 2024-10-05 12:34:50 +13:00

Improve error messages relating to failing to connect to datasources.

This commit is contained in:
Sam Rose 2024-02-05 14:53:05 +00:00
parent 1573242031
commit a773841518
No known key found for this signature in database
2 changed files with 14 additions and 3 deletions

View file

@ -93,7 +93,13 @@
notifications.success("Query executed successfully")
} catch (error) {
notifications.error(`Query Error: ${error.message}`)
if (typeof error.message === "string") {
notifications.error(`Query Error: ${error.message}`)
} else if (typeof error.message?.code === "string") {
notifications.error(`Query Error: ${error.message.code}`)
} else {
notifications.error(`Query Error: ${JSON.stringify(error.message)}`)
}
if (!suppressErrors) {
throw error

View file

@ -202,8 +202,13 @@ class PostgresIntegration extends Sql implements DatasourcePlus {
await this.openConnection()
response.connected = true
} catch (e: any) {
console.log(e)
response.error = e.message as string
if (typeof e.message === "string" && e.message !== "") {
response.error = e.message as string
} else if (typeof e.code === "string" && e.code !== "") {
response.error = e.code
} else {
response.error = "Unknown error"
}
} finally {
await this.closeConnection()
}