mirror of
https://github.com/sosedoff/pgweb.git
synced 2024-12-14 19:21:46 +03:00
api: properly check for errors
This results in NPE when cl.Info() returns an error.
This commit is contained in:
parent
6289e479a5
commit
c4a33206ce
@ -109,11 +109,11 @@ func Connect(c *gin.Context) {
|
||||
info, err := cl.Info()
|
||||
if err == nil {
|
||||
err = setClient(c, cl)
|
||||
if err != nil {
|
||||
cl.Close()
|
||||
c.JSON(400, Error{err.Error()})
|
||||
return
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
cl.Close()
|
||||
c.JSON(400, Error{err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(200, info.Format()[0])
|
||||
@ -163,11 +163,11 @@ func SwitchDb(c *gin.Context) {
|
||||
info, err := cl.Info()
|
||||
if err == nil {
|
||||
err = setClient(c, cl)
|
||||
if err != nil {
|
||||
cl.Close()
|
||||
c.JSON(400, Error{err.Error()})
|
||||
return
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
cl.Close()
|
||||
c.JSON(400, Error{err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
conn.Close()
|
||||
|
Loading…
Reference in New Issue
Block a user