Permalink
Browse files

Fix HTTP POST error handling and correct typos

  • Loading branch information...
1 parent ccd81a6 commit 5872a1e4772177fb02f713feb2d18bb1b5ddbb13 @burke burke committed Nov 26, 2013
Showing with 11 additions and 12 deletions.
  1. +7 −8 airbrake.go
  2. +4 −4 handler.go
View
15 airbrake.go
@@ -88,29 +88,28 @@ func post(params map[string]interface{}) {
buffer := bytes.NewBufferString("")
if err := tmpl.Execute(buffer, params); err != nil {
- log.Printf("Airbreak error: %s", err)
+ log.Printf("Airbrake error: %s", err)
return
}
if Verbose {
- log.Printf("Airbreak payload for endpoint %s: %s", Endpoint, buffer)
+ log.Printf("Airbrake payload for endpoint %s: %s", Endpoint, buffer)
}
response, err := http.Post(Endpoint, "text/xml", buffer)
+ if err != nil {
+ log.Printf("Airbrake error: %s", err)
+ return
+ }
if Verbose {
body, _ := ioutil.ReadAll(response.Body)
log.Printf("response: %s", body)
}
response.Body.Close()
- if err != nil {
- log.Printf("Airbreak error: %s", err)
- return
- }
-
if Verbose {
- log.Printf("Airbreak post: %s status code: %d", params["Error"], response.StatusCode)
+ log.Printf("Airbrake post: %s status code: %d", params["Error"], response.StatusCode)
}
}
View
8 handler.go
@@ -4,10 +4,10 @@ import (
"net/http"
)
-// CapturePanicHandler "middleware".
-// Wraps the http handler so that all panics will be dutifully reported to airbreak
-//
-// Example:
+// CapturePanicHandler "middleware".
+// Wraps the http handler so that all panics will be dutifully reported to airbrake
+//
+// Example:
// http.HandleFunc("/", airbrake.CapturePanicHandler(MyServerFunc))
func CapturePanicHandler(app http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {

0 comments on commit 5872a1e

Please sign in to comment.