Permalink
Browse files

`nut get`: print error.

  • Loading branch information...
1 parent 12437f9 commit 19f70c7861992c081bf5fbc20959c0444a74ed5f @AlekSi committed Feb 24, 2013
Showing with 16 additions and 1 deletion.
  1. +16 −1 nut/get.go
View
@@ -2,6 +2,7 @@ package main
import (
"bytes"
+ "encoding/json"
"fmt"
"go/build"
"io/ioutil"
@@ -131,7 +132,21 @@ func runGet(cmd *Command) {
url := ArgToURL(arg)
b, err := get(url)
- PanicIfErr(err)
+ if err != nil {
+ log.Print(err)
+
+ var body map[string]interface{}
+ err = json.Unmarshal(b, &body)
+ if err != nil {
+ log.Print(err)
+ }
+ m, ok := body["Message"]
+ if ok {
+ log.Fatalf("%s", m)
+ } else {
+ log.Fatalf("Response: %#q", body)
+ }
+ }
nf := new(NutFile)
nf.ReadFrom(bytes.NewReader(b))

0 comments on commit 19f70c7

Please sign in to comment.