forked from railwayapp/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpanic.go
More file actions
45 lines (38 loc) · 1.04 KB
/
Copy pathpanic.go
File metadata and controls
45 lines (38 loc) · 1.04 KB
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
package controller
import (
"context"
"fmt"
"os"
"github.com/railwayapp/cli/constants"
"github.com/railwayapp/cli/entity"
"github.com/railwayapp/cli/ui"
)
func (c *Controller) SendPanic(ctx context.Context, panicErr string, stacktrace string, command string) (bool, error) {
confirmSendPanic()
projectCfg, err := c.cfg.GetProjectConfigs()
if err != nil {
return c.gtwy.SendPanic(ctx, &entity.PanicRequest{
Command: command,
PanicError: panicErr,
Stacktrace: stacktrace,
ProjectID: "",
EnvironmentID: "",
Version: constants.Version,
})
}
return c.gtwy.SendPanic(ctx, &entity.PanicRequest{
Command: command,
PanicError: panicErr,
Stacktrace: stacktrace,
ProjectID: projectCfg.Project,
EnvironmentID: projectCfg.Environment,
Version: constants.Version,
})
}
func confirmSendPanic() {
fmt.Printf("🚨 Looks like something derailed, Press Enter to send error logs (^C to quit)")
fmt.Fscanln(os.Stdin)
ui.StartSpinner(&ui.SpinnerCfg{
Message: "Taking notes...",
})
}