Skip to content

Commit 5fac7ba

Browse files
committed
Improve error handling and pointers for better debugging.
This is to assist debugging benjojo#18 - But should be harmless to everyone else
1 parent c27d983 commit 5fac7ba

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

main.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ func main() {
9999

100100
log.Printf("Listening on: %s", *listenAddress)
101101
http.ListenAndServe(*listenAddress, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
102+
log.Printf("%s - [%s] %s", r.Host, r.Method, r.URL.RawPath)
103+
102104
b, err := ioutil.ReadAll(r.Body)
103105
if err != nil {
104106
panic(err)
@@ -107,7 +109,14 @@ func main() {
107109
amo := alertManOut{}
108110
err = json.Unmarshal(b, &amo)
109111
if err != nil {
110-
panic(err)
112+
if len(b) > 1024 {
113+
log.Printf("Failed to unpack inbound alert request - %s...", string(b[:1023]))
114+
115+
} else {
116+
log.Printf("Failed to unpack inbound alert request - %s", string(b))
117+
}
118+
119+
return
111120
}
112121

113122
groupedAlerts := make(map[string][]alertManAlert)

0 commit comments

Comments
 (0)