Use logger error instead of panic in goja handlers
This commit is contained in:
parent
6bd27d7c79
commit
8024a8420b
|
@ -62,7 +62,7 @@ func cmdDBSeed(cmd *cobra.Command, args []string) {
|
||||||
func graphQLFunc(query string, data interface{}, opt map[string]string) map[string]interface{} {
|
func graphQLFunc(query string, data interface{}, opt map[string]string) map[string]interface{} {
|
||||||
b, err := json.Marshal(data)
|
b, err := json.Marshal(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
logger.Fatal().Err(err).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
@ -85,7 +85,7 @@ func graphQLFunc(query string, data interface{}, opt map[string]string) map[stri
|
||||||
|
|
||||||
st, err := c.buildStmtByRole(role)
|
st, err := c.buildStmtByRole(role)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("graphql query failed: %s", err))
|
logger.Fatal().Err(err).Msg("graphql query failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
buf := &bytes.Buffer{}
|
buf := &bytes.Buffer{}
|
||||||
|
@ -94,47 +94,47 @@ func graphQLFunc(query string, data interface{}, opt map[string]string) map[stri
|
||||||
_, err = t.ExecuteFunc(buf, argMap(c))
|
_, err = t.ExecuteFunc(buf, argMap(c))
|
||||||
|
|
||||||
if err == errNoUserID {
|
if err == errNoUserID {
|
||||||
panic(fmt.Errorf("query requires a user_id"))
|
logger.Fatal().Err(err).Msg("query requires a user_id")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
logger.Fatal().Err(err).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
finalSQL := buf.String()
|
finalSQL := buf.String()
|
||||||
|
|
||||||
tx, err := db.Begin(c)
|
tx, err := db.Begin(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
logger.Fatal().Err(err).Send()
|
||||||
}
|
}
|
||||||
defer tx.Rollback(c)
|
defer tx.Rollback(c)
|
||||||
|
|
||||||
if conf.DB.SetUserID {
|
if conf.DB.SetUserID {
|
||||||
if err := c.setLocalUserID(tx); err != nil {
|
if err := c.setLocalUserID(tx); err != nil {
|
||||||
panic(err)
|
logger.Fatal().Err(err).Send()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var root []byte
|
var root []byte
|
||||||
|
|
||||||
if err = tx.QueryRow(c, finalSQL).Scan(&root); err != nil {
|
if err = tx.QueryRow(c, finalSQL).Scan(&root); err != nil {
|
||||||
panic(fmt.Errorf("sql query failed: %s", err))
|
logger.Fatal().Err(err).Msg("sql query failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := tx.Commit(c); err != nil {
|
if err := tx.Commit(c); err != nil {
|
||||||
panic(err)
|
logger.Fatal().Err(err).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := c.execRemoteJoin(st.qc, st.skipped, root)
|
res, err := c.execRemoteJoin(st.qc, st.skipped, root)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
logger.Fatal().Err(err).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
val := make(map[string]interface{})
|
val := make(map[string]interface{})
|
||||||
|
|
||||||
err = json.Unmarshal(res, &val)
|
err = json.Unmarshal(res, &val)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("failed to deserialize json: %s", err))
|
logger.Fatal().Err(err).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
return val
|
return val
|
||||||
|
|
|
@ -3,7 +3,7 @@ host_port: 0.0.0.0:8080
|
||||||
web_ui: true
|
web_ui: true
|
||||||
|
|
||||||
# debug, info, warn, error, fatal, panic
|
# debug, info, warn, error, fatal, panic
|
||||||
log_level: "info"
|
log_level: "warn"
|
||||||
|
|
||||||
# When production mode is 'true' only queries
|
# When production mode is 'true' only queries
|
||||||
# from the allow list are permitted.
|
# from the allow list are permitted.
|
||||||
|
|
|
@ -7,7 +7,7 @@ host_port: 0.0.0.0:8080
|
||||||
web_ui: false
|
web_ui: false
|
||||||
|
|
||||||
# debug, info, warn, error, fatal, panic, disable
|
# debug, info, warn, error, fatal, panic, disable
|
||||||
log_level: "info"
|
log_level: "warn"
|
||||||
# When production mode is 'true' only queries
|
# When production mode is 'true' only queries
|
||||||
# from the allow list are permitted.
|
# from the allow list are permitted.
|
||||||
# When it's 'false' all queries are saved to the
|
# When it's 'false' all queries are saved to the
|
||||||
|
|
Loading…
Reference in New Issue