1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00

Better exception output

This commit is contained in:
Ryan Dahl 2018-05-23 11:27:56 -04:00
parent 08b327bf3a
commit 602ee0d5a1
4 changed files with 13 additions and 3 deletions

View file

@ -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

View file

@ -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

View file

@ -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()

View file

@ -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)
}
}