Skip to content

More verrbose errors for JSON parsing #2151

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

Merged
merged 1 commit into from
Jul 13, 2016
Merged

More verrbose errors for JSON parsing #2151

merged 1 commit into from
Jul 13, 2016

Conversation

bogdanm
Copy link
Contributor

@bogdanm bogdanm commented Jul 12, 2016

This commit adds information about the location of problematic JSON
files when reporting a JSON parsing error.

Before this commit:

[ERROR] Expecting property name: line 7 column 9 (char 188)

After this commit:

Error parsing 'core/mbed_lib.json':
[ERROR] Expecting property name: line 7 column 9 (char 188)

@bogdanm
Copy link
Contributor Author

bogdanm commented Jul 12, 2016

@0xc0170 @screamerbg

try:
with open(fname, "rt") as f:
return dict_to_ascii(json.load(f, object_pairs_hook=OrderedDict))
except ValueError:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add here IOError too, in case file can't be opened! :)

This commit adds information about the location of problematic JSON
files when reporting a JSON parsing error.

Before this commit:

```
[ERROR] Expecting property name: line 7 column 9 (char 188)
```

After this commit:

```
Error parsing 'core/mbed_lib.json':
[ERROR] Expecting property name: line 7 column 9 (char 188)
```
@bogdanm bogdanm force-pushed the verbose_json_errors branch from d8c56d2 to 33dd3fe Compare July 12, 2016 15:52
@bogdanm
Copy link
Contributor Author

bogdanm commented Jul 12, 2016

Forced-pushed the change suggested by @PrzemekWirkus

@theotherjimmy
Copy link
Contributor

👍

@bogdanm bogdanm merged commit e9d225b into master Jul 13, 2016
@bogdanm bogdanm deleted the verbose_json_errors branch July 13, 2016 07:29
@PrzemekWirkus
Copy link
Contributor

+1

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.

3 participants