mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
Better exception output
This commit is contained in:
parent
08b327bf3a
commit
602ee0d5a1
4 changed files with 13 additions and 3 deletions
3
Makefile
3
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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
3
main.go
3
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()
|
||||
|
|
8
util.go
8
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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue