Improve error messages relating to failing to connect to datasources.
This commit is contained in:
parent
1573242031
commit
a773841518
|
@ -93,7 +93,13 @@
|
||||||
|
|
||||||
notifications.success("Query executed successfully")
|
notifications.success("Query executed successfully")
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (typeof error.message === "string") {
|
||||||
notifications.error(`Query Error: ${error.message}`)
|
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) {
|
if (!suppressErrors) {
|
||||||
throw error
|
throw error
|
||||||
|
|
|
@ -202,8 +202,13 @@ class PostgresIntegration extends Sql implements DatasourcePlus {
|
||||||
await this.openConnection()
|
await this.openConnection()
|
||||||
response.connected = true
|
response.connected = true
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.log(e)
|
if (typeof e.message === "string" && e.message !== "") {
|
||||||
response.error = e.message as string
|
response.error = e.message as string
|
||||||
|
} else if (typeof e.code === "string" && e.code !== "") {
|
||||||
|
response.error = e.code
|
||||||
|
} else {
|
||||||
|
response.error = "Unknown error"
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
await this.closeConnection()
|
await this.closeConnection()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue