From 7e13eada31c6e7e0cc3e4470028da608e2c1771b Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Mon, 30 Aug 2021 21:35:13 -0700 Subject: [PATCH] Report better errors for non-repl languages --- backend/api.js | 4 ++++ cli/src/main.go | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/backend/api.js b/backend/api.js index 70c8f73..433bc8d 100644 --- a/backend/api.js +++ b/backend/api.js @@ -58,6 +58,10 @@ export class Session { try { setTimeout(this.teardown, 3600 * 1000); // max session length of 1hr allSessions.add(this); + this.send({ + event: "langConfig", + config: this.config, + }); const containerArgs = this.privilegedSession(); const containerProc = spawn(containerArgs[0], containerArgs.slice(1)); this.container = { diff --git a/cli/src/main.go b/cli/src/main.go index f79ce45..d15ac46 100644 --- a/cli/src/main.go +++ b/cli/src/main.go @@ -31,6 +31,15 @@ type message struct { Event string `json:"event"` } +type langConfig struct { + message + Config struct { + Id string `json:"id"` + Name string `json:"name"` + Repl string `json:"repl"` + } `json:"config"` +} + type errorMessage struct { message Error string `json:"errorMessage"` @@ -121,6 +130,16 @@ func run() error { return } done1 <- errors.New(msg.Error) + case "langConfig": + var msg langConfig + if err := json.Unmarshal(rawMsg, &msg); err != nil { + done1 <- errors.Wrap(err, "failed to parse websocket message") + return + } + if msg.Config.Repl == "" { + done1 <- fmt.Errorf("%s has no repl, you must provide a file to run", msg.Config.Name) + return + } case "terminalOutput": var msg terminalOutput if err := json.Unmarshal(rawMsg, &msg); err != nil {