" {
74 | t.Errorf("Constructor with nil failed")
75 | }
76 | }
77 |
78 | func ExampleErrorf(x int) (int, error) {
79 | if x%2 == 1 {
80 | return 0, Errorf("can only halve even numbers, got %d", x)
81 | }
82 | return x / 2, nil
83 | }
84 |
85 | func ExampleNewError() (error, error) {
86 | // Wrap io.EOF with the current stack-trace and return it
87 | return nil, New(io.EOF, 0)
88 | }
89 |
90 | func ExampleNewError_skip() {
91 | defer func() {
92 | if err := recover(); err != nil {
93 | // skip 1 frame (the deferred function) and then return the wrapped err
94 | err = New(err, 1)
95 | }
96 | }()
97 | }
98 |
99 | func ExampleError_Stack(err Error) {
100 | fmt.Printf("Error: %s\n%s", err.Error(), err.Stack())
101 | }
102 |
103 | func a() error {
104 | b(5)
105 | return nil
106 | }
107 |
108 | func b(i int) {
109 | c()
110 | }
111 |
112 | func c() {
113 | panic('a')
114 | }
115 |
--------------------------------------------------------------------------------
/vendor/src/github.com/bugsnag/bugsnag-go/examples/appengine/README.md:
--------------------------------------------------------------------------------
1 | This is an example google app-engine app.
2 |
3 | To use it you will need to install the [App Engine
4 | SDK](https://cloud.google.com/appengine/downloads) for Go.
5 |
6 | Then run:
7 |
8 | goapp deploy
9 |
10 | Then open: https://bugsnag-test.appspot.com/ in your web-browser.
11 |
--------------------------------------------------------------------------------
/vendor/src/github.com/bugsnag/bugsnag-go/examples/appengine/app.yaml:
--------------------------------------------------------------------------------
1 | application: bugsnag-test
2 | version: 1
3 | runtime: go
4 | api_version: go1
5 |
6 | handlers:
7 | - url: /.*
8 | script: _go_app
9 |
--------------------------------------------------------------------------------
/vendor/src/github.com/bugsnag/bugsnag-go/examples/appengine/hello.go:
--------------------------------------------------------------------------------
1 | package mellow
2 |
3 | import (
4 | "fmt"
5 | "github.com/bugsnag/bugsnag-go"
6 | "github.com/bugsnag/bugsnag-go/errors"
7 | "net/http"
8 | "os"
9 | )
10 |
11 | func init() {
12 | bugsnag.OnBeforeNotify(func(event *bugsnag.Event, config *bugsnag.Configuration) error {
13 | event.MetaData.AddStruct("original", event.Error.StackFrames())
14 | return nil
15 | })
16 | bugsnag.Configure(bugsnag.Configuration{
17 | APIKey: "066f5ad3590596f9aa8d601ea89af845",
18 | })
19 |
20 | http.HandleFunc("/", bugsnag.HandlerFunc(handler))
21 | }
22 |
23 | func handler(w http.ResponseWriter, r *http.Request) {
24 | fmt.Fprint(w, "welcome")
25 | notifier := bugsnag.New(r)
26 | notifier.Notify(fmt.Errorf("oh hia"), bugsnag.MetaData{"env": {"values": os.Environ()}})
27 | fmt.Fprint(w, "welcome\n")
28 |
29 | panic("zoomg")
30 |
31 | fmt.Fprintf(w, "%#v", errors.Errorf("oahi").StackFrames())
32 | }
33 |
--------------------------------------------------------------------------------
/vendor/src/github.com/bugsnag/bugsnag-go/examples/appengine/mylogs.txt:
--------------------------------------------------------------------------------
1 | 2601:9:8480:11d2:7909:b2e5:3722:ef57 - - [08/Jul/2014:01:16:25 -0700] "GET / HTTP/1.1" 500 0 - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36"
2 | 2601:9:8480:11d2:7909:b2e5:3722:ef57 - - [08/Jul/2014:01:16:25 -0700] "GET /favicon.ico HTTP/1.1" 500 0 - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36"
3 | 2601:9:8480:11d2:7909:b2e5:3722:ef57 - - [08/Jul/2014:01:18:20 -0700] "GET / HTTP/1.1" 500 0 - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36"
4 | 2601:9:8480:11d2:7909:b2e5:3722:ef57 - - [08/Jul/2014:01:18:20 -0700] "GET /favicon.ico HTTP/1.1" 500 0 - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36"
5 |
--------------------------------------------------------------------------------
/vendor/src/github.com/bugsnag/bugsnag-go/examples/http/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "github.com/bugsnag/bugsnag-go"
5 | "log"
6 | "net/http"
7 | )
8 |
9 | func main() {
10 |
11 | http.HandleFunc("/", Get)
12 |
13 | bugsnag.Configure(bugsnag.Configuration{
14 | APIKey: "066f5ad3590596f9aa8d601ea89af845",
15 | })
16 |
17 | log.Println("Serving on 9001")
18 | http.ListenAndServe(":9001", bugsnag.Handler(nil))
19 | }
20 |
21 | func Get(w http.ResponseWriter, r *http.Request) {
22 | w.WriteHeader(200)
23 | w.Write([]byte("OK\n"))
24 |
25 | var a struct{}
26 | crash(a)
27 | }
28 |
29 | func crash(a interface{}) string {
30 | return a.(string)
31 | }
32 |
--------------------------------------------------------------------------------
/vendor/src/github.com/bugsnag/bugsnag-go/examples/revelapp/app/controllers/app.go:
--------------------------------------------------------------------------------
1 | package controllers
2 |
3 | import "github.com/revel/revel"
4 | import "time"
5 |
6 | type App struct {
7 | *revel.Controller
8 | }
9 |
10 | func (c App) Index() revel.Result {
11 | go func() {
12 | time.Sleep(5 * time.Second)
13 | panic("hello!")
14 | }()
15 |
16 | s := make([]string, 0)
17 | revel.INFO.Print(s[0])
18 | return c.Render()
19 | }
20 |
--------------------------------------------------------------------------------
/vendor/src/github.com/bugsnag/bugsnag-go/examples/revelapp/app/init.go:
--------------------------------------------------------------------------------
1 | package app
2 |
3 | import "github.com/revel/revel"
4 | import "github.com/bugsnag/bugsnag-go/revel"
5 |
6 | func init() {
7 | // Filters is the default set of global filters.
8 | revel.Filters = []revel.Filter{
9 | revel.PanicFilter, // Recover from panics and display an error page instead.
10 | bugsnagrevel.Filter, // Send panics to Bugsnag
11 | revel.RouterFilter, // Use the routing table to select the right Action
12 | revel.FilterConfiguringFilter, // A hook for adding or removing per-Action filters.
13 | revel.ParamsFilter, // Parse parameters into Controller.Params.
14 | revel.SessionFilter, // Restore and write the session cookie.
15 | revel.FlashFilter, // Restore and write the flash cookie.
16 | revel.ValidationFilter, // Restore kept validation errors and save new ones from cookie.
17 | revel.I18nFilter, // Resolve the requested language
18 | HeaderFilter, // Add some security based headers
19 | revel.InterceptorFilter, // Run interceptors around the action.
20 | revel.CompressFilter, // Compress the result.
21 | revel.ActionInvoker, // Invoke the action.
22 | }
23 |
24 | // register startup functions with OnAppStart
25 | // ( order dependent )
26 | // revel.OnAppStart(InitDB())
27 | // revel.OnAppStart(FillCache())
28 | }
29 |
30 | // TODO turn this into revel.HeaderFilter
31 | // should probably also have a filter for CSRF
32 | // not sure if it can go in the same filter or not
33 | var HeaderFilter = func(c *revel.Controller, fc []revel.Filter) {
34 | // Add some common security headers
35 | c.Response.Out.Header().Add("X-Frame-Options", "SAMEORIGIN")
36 | c.Response.Out.Header().Add("X-XSS-Protection", "1; mode=block")
37 | c.Response.Out.Header().Add("X-Content-Type-Options", "nosniff")
38 |
39 | fc[0](c, fc[1:]) // Execute the next filter stage.
40 | }
41 |
--------------------------------------------------------------------------------
/vendor/src/github.com/bugsnag/bugsnag-go/examples/revelapp/app/views/App/Index.html:
--------------------------------------------------------------------------------
1 | {{set . "title" "Home"}}
2 | {{template "header.html" .}}
3 |
4 |
14 |
15 |
16 |
17 |
18 | {{template "flash.html" .}}
19 |
20 |
21 |
22 |
23 | {{template "footer.html" .}}
24 |
--------------------------------------------------------------------------------
/vendor/src/github.com/bugsnag/bugsnag-go/examples/revelapp/app/views/debug.html:
--------------------------------------------------------------------------------
1 |
20 |
44 |
45 |
46 |
65 |
--------------------------------------------------------------------------------
/vendor/src/github.com/bugsnag/bugsnag-go/examples/revelapp/app/views/errors/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Not found
5 |
6 |
7 | {{if eq .RunMode "dev"}}
8 | {{template "errors/404-dev.html" .}}
9 | {{else}}
10 | {{with .Error}}
11 |
12 | {{.Title}}
13 |
14 |
15 | {{.Description}}
16 |
17 | {{end}}
18 | {{end}}
19 |
20 |
21 |
--------------------------------------------------------------------------------
/vendor/src/github.com/bugsnag/bugsnag-go/examples/revelapp/app/views/errors/500.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Application error
5 |
6 |
7 | {{if eq .RunMode "dev"}}
8 | {{template "errors/500-dev.html" .}}
9 | {{else}}
10 | Oops, an error occured
11 |
12 | This exception has been logged.
13 |
14 | {{end}}
15 |
16 |
17 |
--------------------------------------------------------------------------------
/vendor/src/github.com/bugsnag/bugsnag-go/examples/revelapp/app/views/flash.html:
--------------------------------------------------------------------------------
1 | {{if .flash.success}}
2 |
3 | {{.flash.success}}
4 |
5 | {{end}}
6 |
7 | {{if or .errors .flash.error}}
8 |
9 | {{if .flash.error}}
10 | {{.flash.error}}
11 | {{end}}
12 |
13 | {{range .errors}}
14 | - {{.}}
15 | {{end}}
16 |
17 |
18 | {{end}}
19 |
--------------------------------------------------------------------------------
/vendor/src/github.com/bugsnag/bugsnag-go/examples/revelapp/app/views/footer.html:
--------------------------------------------------------------------------------
1 | {{if eq .RunMode "dev"}}
2 | {{template "debug.html" .}}
3 | {{end}}
4 |