aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/sqlvm/cmd
diff options
context:
space:
mode:
authorTing-Wei Lan <tingwei.lan@cobinhood.com>2019-02-23 17:47:20 +0800
committerJhih-Ming Huang <jm.huang@cobinhood.com>2019-05-06 10:44:04 +0800
commit3274f055838e0bbc499a24ac58e06a4604d0a322 (patch)
tree410dd752e6eeb8597e59c72a03285bf3ea19f786 /core/vm/sqlvm/cmd
parent7628271e5d363a9a7283efb6f7d8b1b52e392e45 (diff)
downloaddexon-3274f055838e0bbc499a24ac58e06a4604d0a322.tar
dexon-3274f055838e0bbc499a24ac58e06a4604d0a322.tar.gz
dexon-3274f055838e0bbc499a24ac58e06a4604d0a322.tar.bz2
dexon-3274f055838e0bbc499a24ac58e06a4604d0a322.tar.lz
dexon-3274f055838e0bbc499a24ac58e06a4604d0a322.tar.xz
dexon-3274f055838e0bbc499a24ac58e06a4604d0a322.tar.zst
dexon-3274f055838e0bbc499a24ac58e06a4604d0a322.zip
core: vm: sqlvm: ast: handle error in AST printer
Catch the error reported by fmt.Fprintf and report it to the caller.
Diffstat (limited to 'core/vm/sqlvm/cmd')
-rw-r--r--core/vm/sqlvm/cmd/ast-printer/main.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/core/vm/sqlvm/cmd/ast-printer/main.go b/core/vm/sqlvm/cmd/ast-printer/main.go
index 33710f2b0..d62cb4fc8 100644
--- a/core/vm/sqlvm/cmd/ast-printer/main.go
+++ b/core/vm/sqlvm/cmd/ast-printer/main.go
@@ -15,12 +15,18 @@ func main() {
flag.Parse()
+ fmt.Fprintf(os.Stderr, "detail: %t\n", detail)
s := []byte(flag.Arg(0))
- n, err := parser.Parse(s)
- fmt.Printf("detail: %t\n", detail)
- if err != nil {
- fmt.Fprintf(os.Stderr, "err:\n%+v\n", err)
+ n, parseErr := parser.Parse(s)
+ b, printErr := ast.PrintAST(os.Stdout, n, s, " ", detail)
+ if parseErr != nil {
+ fmt.Fprintf(os.Stderr, "Parse error:\n%+v\n", parseErr)
+ }
+ if printErr != nil {
+ fmt.Fprintf(os.Stderr, "Print error:\n%+v\n", printErr)
+ }
+ fmt.Fprintf(os.Stderr, "Output size: %d bytes\n", b)
+ if parseErr != nil || printErr != nil {
os.Exit(1)
}
- ast.PrintAST(os.Stdout, n, s, " ", detail)
}