Improve error messages.
Attempt to determine if error when sending a command is due to auth issue and give more useful error in that case.
This commit is contained in:
parent
9dbf75029f
commit
606262514b
1 changed files with 6 additions and 1 deletions
|
@ -7,6 +7,7 @@ package btcjson
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Message contains a message to be sent to the bitcoin client.
|
||||
|
@ -741,7 +742,11 @@ func ReadResultCmd(cmd string, message []byte) (Reply, error) {
|
|||
var objmap map[string]json.RawMessage
|
||||
err = json.Unmarshal(message, &objmap)
|
||||
if err != nil {
|
||||
if strings.Contains(string(message), "401 Unauthorized.") {
|
||||
err = fmt.Errorf("Authentication error.")
|
||||
} else {
|
||||
err = fmt.Errorf("Error unmarshalling json reply: %v", err)
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
// Take care of the parts that are the same for all replies.
|
||||
|
|
Loading…
Reference in a new issue