MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / wshandleError

Function wshandleError

core/app/api/v2/script_library.go:256–274  ·  view source on GitHub ↗
(ws *websocket.Conn, err error)

Source from the content-addressed store, hash-verified

254}
255
256func wshandleError(ws *websocket.Conn, err error) bool {
257 if err != nil {
258 global.LOG.Errorf("handler ws faled:, err: %v", err)
259 dt := time.Now().Add(time.Second)
260 if ctlerr := ws.WriteControl(websocket.CloseMessage, []byte(err.Error()), dt); ctlerr != nil {
261 wsData, marshalErr := json.Marshal(terminal.WsMsg{
262 Type: terminal.WsMsgCmd,
263 Data: base64.StdEncoding.EncodeToString([]byte(err.Error())),
264 })
265 if marshalErr != nil {
266 _ = ws.WriteMessage(websocket.TextMessage, []byte("{\"type\":\"cmd\",\"data\":\"failed to encoding to json\"}"))
267 } else {
268 _ = ws.WriteMessage(websocket.TextMessage, wsData)
269 }
270 }
271 return true
272 }
273 return false
274}

Callers 1

RunScriptMethod · 0.70

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected