File: hello.go

package info (click to toggle)
golang-github-bugsnag-bugsnag-go 1.0.5%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 456 kB
  • sloc: makefile: 9
file content (32 lines) | stat: -rw-r--r-- 768 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package mellow

import (
	"fmt"
	"github.com/bugsnag/bugsnag-go"
	"github.com/bugsnag/bugsnag-go/errors"
	"net/http"
	"os"
)

func init() {
	bugsnag.OnBeforeNotify(func(event *bugsnag.Event, config *bugsnag.Configuration) error {
		event.MetaData.AddStruct("original", event.Error.StackFrames())
		return nil
	})
	bugsnag.Configure(bugsnag.Configuration{
		APIKey: "066f5ad3590596f9aa8d601ea89af845",
	})

	http.HandleFunc("/", bugsnag.HandlerFunc(handler))
}

func handler(w http.ResponseWriter, r *http.Request) {
	fmt.Fprint(w, "welcome")
	notifier := bugsnag.New(r)
	notifier.Notify(fmt.Errorf("oh hia"), bugsnag.MetaData{"env": {"values": os.Environ()}})
	fmt.Fprint(w, "welcome\n")

	panic("zoomg")

	fmt.Fprintf(w, "%#v", errors.Errorf("oahi").StackFrames())
}