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

Catch sourcemap JSON parse exception. #11

Merged
merged 2 commits into from
Jan 8, 2016

Conversation

masoncj
Copy link
Contributor

@masoncj masoncj commented Jan 8, 2016

@richardxia CC @jdavisp3

Catch and log exception on invalid sourcemap.

Tested by stopping in debugger, manually truncating sourcemap and continueing:

Warning: could not read valid sourcemap JSON from /Users/cmason/counsyl/code/civet/testsite/precompiled_assets/coffee/library.map. Exception is:
Expecting object: line 4 column 25 (char 66)

Contents are:
{
  "version": 3,
  "file": "library.js",
  "sourceRoot": "../..",

map_data['sourceRoot'] = ''
map_data['sources'] = [os.path.basename(src_path)]
with open(map_path, 'w') as f:
json.dump(map_data, f)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it a good idea to open two file handles to the same file, one in read mode and one in write mode? I wasn't able to find anything on the internet about this, but it worries me slightly (is there a potential to self deadlock?).

Since you have a return statement in the the except case, you could just close the original file handle and open a new one, similar to the old code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, derp, thanks. 0a28db6

@richardxia
Copy link
Contributor

Cool, LGTM!

masoncj added a commit that referenced this pull request Jan 8, 2016
Catch sourcemap JSON parse exception.
@masoncj masoncj merged commit d5db95c into counsyl:master Jan 8, 2016
@masoncj
Copy link
Contributor Author

masoncj commented Jan 8, 2016

Thanks @richardxia!

@masoncj masoncj deleted the catch_sourcemap_error branch January 8, 2016 20:52
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