Report errors correctly
This commit is contained in:
parent
0d2e113319
commit
4436f91ec9
|
@ -29,6 +29,11 @@ type message struct {
|
||||||
Event string `json:"event"`
|
Event string `json:"event"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type errorMessage struct {
|
||||||
|
message
|
||||||
|
Error string `json:"errorMessage"`
|
||||||
|
}
|
||||||
|
|
||||||
type terminalInput struct {
|
type terminalInput struct {
|
||||||
message
|
message
|
||||||
Input string `json:"input"`
|
Input string `json:"input"`
|
||||||
|
@ -100,6 +105,13 @@ func run() error {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
switch genericMsg.Event {
|
switch genericMsg.Event {
|
||||||
|
case "error":
|
||||||
|
var msg errorMessage
|
||||||
|
if err := json.Unmarshal(rawMsg, &msg); err != nil {
|
||||||
|
done1 <- errors.Wrap(err, "failed to parse websocket message")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
done1 <- errors.New(msg.Error)
|
||||||
case "terminalOutput":
|
case "terminalOutput":
|
||||||
var msg terminalOutput
|
var msg terminalOutput
|
||||||
if err := json.Unmarshal(rawMsg, &msg); err != nil {
|
if err := json.Unmarshal(rawMsg, &msg); err != nil {
|
||||||
|
@ -162,6 +174,8 @@ func run() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
log.SetPrefix("riju: ")
|
||||||
|
log.SetFlags(0)
|
||||||
kong.Parse(&cli)
|
kong.Parse(&cli)
|
||||||
exitStatus := 0
|
exitStatus := 0
|
||||||
if err := run(); err != nil {
|
if err := run(); err != nil {
|
||||||
|
|
Loading…
Reference in New Issue