Skip to content

Commit f0567e1

Browse files
committed
improve error message
1 parent 9358a7f commit f0567e1

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

internal/errors/error.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ type InvalidUnmarshalError struct {
1111

1212
func (e *InvalidUnmarshalError) Error() string {
1313
if e.Type == nil {
14-
return "php: Unmarshal(nil)"
14+
return "php-serialize: Unmarshal(nil)"
1515
}
1616

1717
if e.Type.Kind() != reflect.Ptr {
18-
return fmt.Sprintf("php: Unmarshal(non-pointer %s)", e.Type)
18+
return fmt.Sprintf("php-serialize: Unmarshal(non-pointer %s)", e.Type)
1919
}
20-
return fmt.Sprintf("php: Unmarshal(nil %s)", e.Type)
20+
return fmt.Sprintf("php-serialize: Unmarshal(nil %s)", e.Type)
2121
}
2222

2323
// A SyntaxError is a description of a JSON syntax error.
@@ -40,11 +40,11 @@ type UnmarshalTypeError struct {
4040

4141
func (e *UnmarshalTypeError) Error() string {
4242
if e.Struct != "" || e.Field != "" {
43-
return fmt.Sprintf("php: cannot unmarshal %s into Go struct field %s.%s of type %s (offset %d)",
43+
return fmt.Sprintf("php-serialize: cannot unmarshal %s into Go struct field %s.%s of type %s (offset %d)",
4444
e.Value, e.Struct, e.Field, e.Type, e.Offset,
4545
)
4646
}
47-
return fmt.Sprintf("php: cannot unmarshal %s into Go value of type %s (offset: %d)", e.Value, e.Type, e.Offset)
47+
return fmt.Sprintf("php-serialize: cannot unmarshal %s into Go value of type %s (offset: %d)", e.Value, e.Type, e.Offset)
4848
}
4949

5050
// An UnsupportedTypeError is returned by Marshal when attempting
@@ -54,7 +54,7 @@ type UnsupportedTypeError struct {
5454
}
5555

5656
func (e *UnsupportedTypeError) Error() string {
57-
return fmt.Sprintf("php: unsupported type: %s", e.Type)
57+
return fmt.Sprintf("php-serialize: unsupported type: %s", e.Type)
5858
}
5959

6060
type UnsupportedValueError struct {
@@ -63,7 +63,7 @@ type UnsupportedValueError struct {
6363
}
6464

6565
func (e *UnsupportedValueError) Error() string {
66-
return fmt.Sprintf("php: unsupported value: %s", e.Str)
66+
return fmt.Sprintf("php-serialize: unsupported value: %s", e.Str)
6767
}
6868

6969
func ErrSyntax(msg string, offset int64) *SyntaxError {
@@ -72,52 +72,52 @@ func ErrSyntax(msg string, offset int64) *SyntaxError {
7272

7373
func ErrExceededMaxDepth(c byte, cursor int64) *SyntaxError {
7474
return &SyntaxError{
75-
msg: fmt.Sprintf(`invalid character "%c" exceeded max depth`, c),
75+
msg: fmt.Sprintf(`php-serialize: invalid character "%c" exceeded max depth`, c),
7676
Offset: cursor,
7777
}
7878
}
7979

8080
func ErrUnexpectedStart(typ string, buf []byte, cursor int64) *SyntaxError {
8181
return &SyntaxError{
82-
msg: fmt.Sprintf("php: unexpected %c at beginning of %s", buf[cursor], typ),
82+
msg: fmt.Sprintf("php-serialize: unexpected %c at beginning of %s", buf[cursor], typ),
8383
Offset: cursor,
8484
}
8585
}
8686

8787
func ErrUnexpectedEnd(msg string, cursor int64) *SyntaxError {
8888
return &SyntaxError{
89-
msg: fmt.Sprintf("php: %s unexpected end of input", msg),
89+
msg: fmt.Sprintf("php-serialize: %s unexpected end of input", msg),
9090
Offset: cursor,
9191
}
9292
}
9393

9494
func ErrUnexpected(msg string, cursor int64, c byte) *SyntaxError {
95-
return &SyntaxError{msg: fmt.Sprintf("php: expecting %s, get char '%c' instead", msg, c), Offset: cursor}
95+
return &SyntaxError{msg: fmt.Sprintf("php-serialize: expecting %s, get char '%c' instead", msg, c), Offset: cursor}
9696
}
9797

9898
func ErrInvalidCharacter(c byte, context string, cursor int64) *SyntaxError {
9999
if c == 0 {
100100
return &SyntaxError{
101-
msg: fmt.Sprintf("php: invalid character as %s", context),
101+
msg: fmt.Sprintf("php-serialize: invalid character as %s", context),
102102
Offset: cursor,
103103
}
104104
}
105105
return &SyntaxError{
106-
msg: fmt.Sprintf("php: invalid character %c as %s", c, context),
106+
msg: fmt.Sprintf("php-serialize: invalid character %c as %s", c, context),
107107
Offset: cursor,
108108
}
109109
}
110110

111111
func ErrInvalidBeginningOfValue(c byte, cursor int64) *SyntaxError {
112112
return &SyntaxError{
113-
msg: fmt.Sprintf("invalid character '%c' looking for beginning of value", c),
113+
msg: fmt.Sprintf("php-serialize: invalid character '%c' looking for beginning of value", c),
114114
Offset: cursor,
115115
}
116116
}
117117

118118
func ErrInvalidBeginningOfArray(c byte, cursor int64) *SyntaxError {
119119
return &SyntaxError{
120-
msg: fmt.Sprintf("invalid character '%c' looking for beginning of array", c),
120+
msg: fmt.Sprintf("php-serialize: invalid character '%c' looking for beginning of array", c),
121121
Offset: cursor,
122122
}
123123
}
@@ -135,5 +135,5 @@ type overflowError struct {
135135
}
136136

137137
func (o overflowError) Error() string {
138-
return fmt.Sprintf("php: %v overflow type %s", o.v, o.t)
138+
return fmt.Sprintf("php-serialize: %v overflow type %s", o.v, o.t)
139139
}

0 commit comments

Comments
 (0)