Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add more friendly warnings #671

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading