Show better errors in the logs
This commit is contained in:
parent
f0da1eeb48
commit
29217bf0cc
25
websocket.go
25
websocket.go
|
@ -275,7 +275,7 @@ func (wsh *WebsocketHandler) SendErrorJson(err error) error {
|
||||||
wsh.Mutex.Lock()
|
wsh.Mutex.Lock()
|
||||||
defer wsh.Mutex.Unlock()
|
defer wsh.Mutex.Unlock()
|
||||||
|
|
||||||
message := "an unexpected error was encountered during the websocket lifecycle"
|
message := "an unexpected error was encountered while handling this request"
|
||||||
if wsh.JWT != nil && wsh.JWT.HasPermission(PermissionReceiveErrors) {
|
if wsh.JWT != nil && wsh.JWT.HasPermission(PermissionReceiveErrors) {
|
||||||
message = err.Error()
|
message = err.Error()
|
||||||
}
|
}
|
||||||
|
@ -285,7 +285,12 @@ func (wsh *WebsocketHandler) SendErrorJson(err error) error {
|
||||||
wsm := WebsocketMessage{Event: ErrorEvent}
|
wsm := WebsocketMessage{Event: ErrorEvent}
|
||||||
wsm.Args = []string{m}
|
wsm.Args = []string{m}
|
||||||
|
|
||||||
zap.S().Warnw("an error was encountered in the websocket process", zap.String("error_identifier", u.String()), zap.Error(err))
|
zap.S().Errorw(
|
||||||
|
"an error was encountered in the websocket process",
|
||||||
|
zap.String("server", wsh.Server.Uuid),
|
||||||
|
zap.String("error_identifier", u.String()),
|
||||||
|
zap.Error(err),
|
||||||
|
)
|
||||||
|
|
||||||
return wsh.Connection.WriteJSON(wsm)
|
return wsh.Connection.WriteJSON(wsm)
|
||||||
}
|
}
|
||||||
|
@ -332,24 +337,18 @@ func (wsh *WebsocketHandler) HandleInbound(m WebsocketMessage) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
|
||||||
switch strings.Join(m.Args, "") {
|
switch strings.Join(m.Args, "") {
|
||||||
case "start":
|
case "start":
|
||||||
err = wsh.Server.Environment.Start()
|
return wsh.Server.Environment.Start()
|
||||||
break
|
|
||||||
case "stop":
|
case "stop":
|
||||||
err = wsh.Server.Environment.Stop()
|
return wsh.Server.Environment.Stop()
|
||||||
break
|
|
||||||
case "restart":
|
case "restart":
|
||||||
break
|
return nil
|
||||||
case "kill":
|
case "kill":
|
||||||
err = wsh.Server.Environment.Terminate(os.Kill)
|
return wsh.Server.Environment.Terminate(os.Kill)
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
return nil
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case SendServerLogsEvent:
|
case SendServerLogsEvent:
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user