summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-05-23 11:27:56 -0400
committerRyan Dahl <ry@tinyclouds.org>2018-05-23 11:27:56 -0400
commit602ee0d5a1b092faf8f29cac0727a28640aac0b0 (patch)
treed050b0f2d12ec989d40305bf43d79a0633905b74
parent08b327bf3afd7ad180fe807c4292c23cc6942b56 (diff)
Better exception output
-rw-r--r--Makefile3
-rw-r--r--dispatch.go2
-rw-r--r--main.go3
-rw-r--r--util.go8
4 files changed, 13 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 613930781..fca2bc646 100644
--- a/Makefile
+++ b/Makefile
@@ -14,11 +14,12 @@ TS_FILES = \
GO_FILES = \
assets.go \
deno_dir.go \
+ deno_dir_test.go \
dispatch.go \
main.go \
- main_test.go \
msg.pb.go \
os.go \
+ os_test.go \
timers.go \
util.go
diff --git a/dispatch.go b/dispatch.go
index 09e5bad9f..33b1fdca9 100644
--- a/dispatch.go
+++ b/dispatch.go
@@ -73,7 +73,7 @@ func DispatchLoop() {
case msg := <-resChan:
out, err := proto.Marshal(msg)
err = worker.SendBytes(out)
- check(err)
+ exitOnError(err)
case <-doneChan:
// All goroutines have completed. Now we can exit main().
return
diff --git a/main.go b/main.go
index 32f011e91..7c6fdfbd0 100644
--- a/main.go
+++ b/main.go
@@ -52,7 +52,8 @@ func main() {
InitTimers()
main_js := stringAsset("main.js")
- check(worker.Load("/main.js", main_js))
+ err := worker.Load("/main.js", main_js)
+ exitOnError(err)
main_map := stringAsset("main.map")
cwd, err := os.Getwd()
diff --git a/util.go b/util.go
index 3e0ac6374..9fab27238 100644
--- a/util.go
+++ b/util.go
@@ -2,6 +2,7 @@ package main
import (
"net/url"
+ "os"
)
func assert(cond bool, msg string) {
@@ -21,3 +22,10 @@ func check(e error) {
panic(e)
}
}
+
+func exitOnError(err error) {
+ if err != nil {
+ os.Stderr.WriteString(err.Error())
+ os.Exit(1)
+ }
+}