more info on json errors
This commit is contained in:
parent
e03abad012
commit
e6ba61fce2
1 changed files with 6 additions and 0 deletions
|
@ -2,7 +2,9 @@ package peer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
ee "errors"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -220,6 +222,10 @@ func (s *Server) handleCompositeRequest(data []byte) ([]byte, error) {
|
||||||
var request compositeRequest
|
var request compositeRequest
|
||||||
err := json.Unmarshal(data, &request)
|
err := json.Unmarshal(data, &request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
var je json.SyntaxError
|
||||||
|
if ee.As(err, &je) {
|
||||||
|
return nil, errors.Err("invalid json at offset %d in data %s", je.Offset, hex.EncodeToString(data))
|
||||||
|
}
|
||||||
return nil, errors.Err(err)
|
return nil, errors.Err(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue