-
Notifications
You must be signed in to change notification settings - Fork 623
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
CASSGO-38 Marshal error messages enhancement #1838
base: trunk
Are you sure you want to change the base?
Conversation
bb0dab6
to
c3dcd98
Compare
marshal.go
Outdated
@@ -333,7 +333,7 @@ func marshalVarchar(info TypeInfo, value interface{}) ([]byte, error) { | |||
case k == reflect.Slice && t.Elem().Kind() == reflect.Uint8: | |||
return rv.Bytes(), nil | |||
} | |||
return nil, marshalErrorf("can not marshal %T into %s", value, info) | |||
return nil, marshalErrorf("can not marshal %T into %s. Accepted types: Marshaler, string, []byte, unsetColumn.", value, info) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unsetColumn
is not an exported type, so the driver doesn't have to expose it to the user. There is a UnsetValue
global var of type unsetColumn
which is meant to be used to ignore writing. You can find it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, refactored
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant to change unsetColumn to UnsetValue, not to delete it at all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, fixed.
marshal.go
Outdated
@@ -2280,7 +2280,7 @@ func marshalUDT(info TypeInfo, value interface{}) ([]byte, error) { | |||
} | |||
|
|||
if k.Kind() != reflect.Struct || !k.IsValid() { | |||
return nil, marshalErrorf("cannot marshal %T into %s", value, info) | |||
return nil, marshalErrorf("cannot marshal %T into %s. Accepted types: Marshaler, unsetColumn, UDTMarshaler, UDTMarshaler, map[string]interface{}, struct.", value, info) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here UDTMarshaler is duplicated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
f4a0127
to
dbec58a
Compare
dbec58a
to
d6550c9
Compare
marshal.go
Outdated
@@ -2208,7 +2210,7 @@ func unmarshalTuple(info TypeInfo, data []byte, value interface{}) error { | |||
return nil | |||
} | |||
|
|||
return unmarshalErrorf("cannot unmarshal %s into %T", info, value) | |||
return unmarshalErrorf("cannot unmarshal %s into %T. Accepted types: struct, []interface{}, array, slice.", info, value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unmarshaler is also accepted I think. Also the accepted types other than []interface{}
have to be a pointer if I'm reading the code correctly (so *struct, *array, *slice
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Thank you.
marshal.go
Outdated
@@ -1706,7 +1708,7 @@ func unmarshalList(info TypeInfo, data []byte, value interface{}) error { | |||
} | |||
return nil | |||
} | |||
return unmarshalErrorf("can not unmarshal %s into %T", info, value) | |||
return unmarshalErrorf("can not unmarshal %s into %T. Accepted types: slice, array.", info, value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it has to be *slice, *array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
marshal.go
Outdated
@@ -2392,7 +2394,7 @@ func unmarshalUDT(info TypeInfo, data []byte, value interface{}) error { | |||
} | |||
k := rv.Elem() | |||
if k.Kind() != reflect.Struct || !k.IsValid() { | |||
return unmarshalErrorf("cannot unmarshal %s into %T", info, value) | |||
return unmarshalErrorf("cannot unmarshal %s into %T. Accepted types: Unmarshaler, UDTUnmarshaler, *map[string]interface{}, struct.", info, value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*struct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
d6550c9
to
74254c8
Compare
This PR provides marshal/unmarshal error messages enhancement.
According to #671 errors were updated by the supported types list.