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

Type mismatch errors can be almost impossible to find through error messages #696

Closed
mbr opened this Issue Feb 13, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@mbr

mbr commented Feb 13, 2017

Have a look at the following (almost) minimal example program:

https://gist.github.com/mbr/78fabb54480549ac89ef8c98d9c186c6

The issue here is that a BigInt is used in the table! macro call where there should be an Integer (due to how the SQL migration is setup. Also, User.id needs to be corrected to i32).

The resulting error message (UnexpectedEOF) makes this not that uncommon error very cryptic. Returning a better error might improved usability by quite a bit.

sgrif added a commit that referenced this issue Feb 13, 2017

Provide a more helpful error message when to few bytes were received
We have a debug check for the semi-common error of mislabeling a
field/expression to a type which is too small. We originally added these
because the value would actually deserialize successfully, but to the
wrong value. We didn't add checks for the "too few bytes" case, as it
would have errored anyway and seemed less common.

However, the error message received when one does make this mistake is
not terribly helpful. We can add an additional check in debug mode to
give a bit more information when someone does make this mistake.

We should see if we can provide some more general improvements to an
error generated by `DeserializationError` in the future. Including the
column name would go a long way, but is a bit larger in scope.

Fixes #696.

sgrif added a commit that referenced this issue Feb 13, 2017

Provide a more helpful error message when too few bytes were received
We have a debug check for the semi-common error of mislabeling a
field/expression to a type which is too small. We originally added these
because the value would actually deserialize successfully, but to the
wrong value. We didn't add checks for the "too few bytes" case, as it
would have errored anyway and seemed less common.

However, the error message received when one does make this mistake is
not terribly helpful. We can add an additional check in debug mode to
give a bit more information when someone does make this mistake.

We should see if we can provide some more general improvements to an
error generated by `DeserializationError` in the future. Including the
column name would go a long way, but is a bit larger in scope.

Fixes #696.

@sgrif sgrif closed this in #697 Feb 15, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment