0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-08 07:16:56 -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 = \ GO_FILES = \
assets.go \ assets.go \
deno_dir.go \ deno_dir.go \
deno_dir_test.go \
dispatch.go \ dispatch.go \
main.go \ main.go \
main_test.go \
msg.pb.go \ msg.pb.go \
os.go \ os.go \
os_test.go \
timers.go \ timers.go \
util.go util.go

View file

@ -73,7 +73,7 @@ func DispatchLoop() {
case msg := <-resChan: case msg := <-resChan:
out, err := proto.Marshal(msg) out, err := proto.Marshal(msg)
err = worker.SendBytes(out) err = worker.SendBytes(out)
check(err) exitOnError(err)
case <-doneChan: case <-doneChan:
// All goroutines have completed. Now we can exit main(). // All goroutines have completed. Now we can exit main().
return return

View file

@ -52,7 +52,8 @@ func main() {
InitTimers() InitTimers()
main_js := stringAsset("main.js") 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") main_map := stringAsset("main.map")
cwd, err := os.Getwd() cwd, err := os.Getwd()

View file

@ -2,6 +2,7 @@ package main
import ( import (
"net/url" "net/url"
"os"
) )
func assert(cond bool, msg string) { func assert(cond bool, msg string) {
@ -21,3 +22,10 @@ func check(e error) {
panic(e) panic(e)
} }
} }
func exitOnError(err error) {
if err != nil {
os.Stderr.WriteString(err.Error())
os.Exit(1)
}
}