mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-22 17:10:10 +00:00
add rough error logging for read/write errors
This commit is contained in:
parent
c84ea17af4
commit
d4a92adc65
5
api.go
5
api.go
@ -207,7 +207,10 @@ func (app *appContext) getOmbiUser(jfID string) (map[string]interface{}, int, er
|
|||||||
return nil, code, err
|
return nil, code, err
|
||||||
}
|
}
|
||||||
username := jfUser["Name"].(string)
|
username := jfUser["Name"].(string)
|
||||||
email := app.storage.emails[jfID].(string)
|
email := ""
|
||||||
|
if e, ok := app.storage.emails[jfID]; ok {
|
||||||
|
email := e.(string)
|
||||||
|
}
|
||||||
for _, ombiUser := range ombiUsers {
|
for _, ombiUser := range ombiUsers {
|
||||||
ombiAddr := ""
|
ombiAddr := ""
|
||||||
if a, ok := ombiUser["emailAddress"]; ok && a != nil {
|
if a, ok := ombiUser["emailAddress"]; ok && a != nil {
|
||||||
|
@ -11,6 +11,7 @@ type TimeoutHandler func()
|
|||||||
// NewTimeoutHandler returns a new Timeout handler.
|
// NewTimeoutHandler returns a new Timeout handler.
|
||||||
func NewTimeoutHandler(name, addr string, noFail bool) TimeoutHandler {
|
func NewTimeoutHandler(name, addr string, noFail bool) TimeoutHandler {
|
||||||
return func() {
|
return func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
out := fmt.Sprintf("Failed to authenticate with %s @ %s: Timed out", name, addr)
|
out := fmt.Sprintf("Failed to authenticate with %s @ %s: Timed out", name, addr)
|
||||||
if noFail {
|
if noFail {
|
||||||
log.Print(out)
|
log.Print(out)
|
||||||
@ -18,4 +19,5 @@ func NewTimeoutHandler(name, addr string, noFail bool) TimeoutHandler {
|
|||||||
log.Fatalf(out)
|
log.Fatalf(out)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -172,6 +173,9 @@ func loadJSON(path string, obj interface{}) error {
|
|||||||
file = []byte("{}")
|
file = []byte("{}")
|
||||||
}
|
}
|
||||||
err = json.Unmarshal(file, &obj)
|
err = json.Unmarshal(file, &obj)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("ERROR: Failed to read \"%s\": %s", path, err)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,5 +185,8 @@ func storeJSON(path string, obj interface{}) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = ioutil.WriteFile(path, data, 0644)
|
err = ioutil.WriteFile(path, data, 0644)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("ERROR: Failed to write to \"%s\": %s", path, err)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user