-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
46 lines (36 loc) · 874 Bytes
/
main.go
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"fmt"
"os"
"runtime/debug"
"time"
"github.com/formancehq/numscript/cmd"
"github.com/getsentry/sentry-go"
)
// This has to be set dynamically via the following flag:
// -ldflags "-X main.Version=0.0.1"
var Version string = "develop"
func recoverPanic() {
if Version == "develop" {
return
}
r := recover()
if r == nil {
return
}
errMsg := fmt.Sprintf("[uncaught panic]@%s: %s\n%s\n", Version, r, string(debug.Stack()))
os.Stderr.Write([]byte(errMsg))
sentry.CaptureMessage(errMsg)
sentry.Flush(2 * time.Second)
}
func main() {
sentry.Init(sentry.ClientOptions{
Dsn: "https://b8b6cfd5dab95e1258d80963c3db73bf@o4504394442539008.ingest.us.sentry.io/4507623538884608",
AttachStacktrace: true,
})
defer recoverPanic()
defer sentry.Flush(2 * time.Second)
cmd.Execute(cmd.CliOptions{
Version: Version,
})
}