diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2018-05-23 11:27:56 -0400 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-05-23 11:27:56 -0400 |
commit | 602ee0d5a1b092faf8f29cac0727a28640aac0b0 (patch) | |
tree | d050b0f2d12ec989d40305bf43d79a0633905b74 | |
parent | 08b327bf3afd7ad180fe807c4292c23cc6942b56 (diff) |
Better exception output
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | dispatch.go | 2 | ||||
-rw-r--r-- | main.go | 3 | ||||
-rw-r--r-- | util.go | 8 |
4 files changed, 13 insertions, 3 deletions
@@ -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 @@ -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() @@ -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) + } +} |