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

Improve error reporting of the serde csv serializer. #317

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jstranik
Copy link

@jstranik jstranik commented May 3, 2023

Make the error messages to show also the field and value that failed to serialize.

Example of an error before the change:

Error Parsing Data: CSV deserialize error: record 1 (line: 2, byte: 549): trailing input.

The new improved error message is now displayed as:

Error Parsing Data: CSV deserialize error: record 1 (line: 2, byte: 549): trailing input. (Field 'trade_timestamp' has a value '2023-04-04T09:46:45.000Z')

Notice the field name and field value that caused problem during the import.

Make the error messages to show also the field and value that failed to
serialize.

Example of an error before the change:
>  Error Parsing Data: CSV deserialize error: record 1 (line: 2, byte: 549): trailing input.

The new improved error message is now displayed as:
> Error Parsing Data: CSV deserialize error: record 1 (line: 2, byte: 549): trailing input. (Field 'trade_timestamp' has a value '2023-04-04T09:46:45.000Z')
@schell
Copy link

schell commented Sep 30, 2024

This would be great. Is there any other way to map an error back to the field that failed to parse?

@schell
Copy link

schell commented Sep 30, 2024

For anyone else following along - you can match on Error::kind(), and the Deserialize variant's err has a field() function that will give you the field index...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants