Skip to content

Commit

Permalink
chore: add more friendly warnings (#671)
Browse files Browse the repository at this point in the history
  • Loading branch information
liuq19 committed Jul 16, 2024
1 parent 456a3b9 commit 125ff79
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ast/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (self SyntaxError) description() string {

/* check for empty source */
if self.Src == "" {
return fmt.Sprintf("no sources available: %#v", self)
return fmt.Sprintf("no sources available, the input json is empty: %#v", self)
}

/* prevent slicing before the beginning */
Expand Down
2 changes: 1 addition & 1 deletion internal/decoder/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (self SyntaxError) Description() string {
func (self SyntaxError) description() string {
/* check for empty source */
if self.Src == "" {
return fmt.Sprintf("no sources available: %#v", self)
return fmt.Sprintf("no sources available, the input json is empty: %#v", self)
}

p, x, q, y := calcBounds(len(self.Src), self.Pos)
Expand Down
2 changes: 1 addition & 1 deletion internal/encoder/vars/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const (
func GoPanic(code int, val unsafe.Pointer) {
switch(code){
case PanicNilPointerOfNonEmptyString:
panic(fmt.Sprintf("val: %#v has nil pointer while its length is not zero!", (*rt.GoString)(val)))
panic(fmt.Sprintf("val: %#v has nil pointer while its length is not zero!\nThis is a nil pointer exception (NPE) problem. There might be a data race issue. It is recommended to execute the tests related to the code with the `-race` compile flag to detect the problem.", (*rt.GoString)(val)))
default:
panic("encoder error!")
}
Expand Down

0 comments on commit 125ff79

Please sign in to comment.