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

Formatting errors aren't properly handled when auto_format is enabled #32

Closed
vladfaust opened this issue Jan 2, 2018 · 8 comments
Closed
Labels

Comments

@vladfaust
Copy link
Contributor

vladfaust commented Jan 2, 2018

Given this file:

class Foo <

This is what I've got in the console:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 818, in run_
    return self.run(edit)
  File "crystal_format in /home/faust/.config/sublime-text-3/Installed Packages/sublime-crystal.sublime-package", line 52, in run
  File "./python3.3/json/__init__.py", line 316, in loads
  File "./python3.3/json/decoder.py", line 351, in decode
  File "./python3.3/json/decoder.py", line 369, in raw_decode
ValueError: No JSON object could be decoded
Traceback (most recent call last):
  File "./python3.3/json/decoder.py", line 367, in raw_decode
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 818, in run_
    return self.run(edit)

... and so on

Basic formatting works, but if there is an error in the code, it's not handled properly - no message is given except these errors in the console.

@vladfaust vladfaust changed the title It doesn't work with Crystal 0.24.1 anymore Crystal 0.24.1 broke errors handling Jan 2, 2018
@vladfaust
Copy link
Contributor Author

Any updates?

@vladfaust
Copy link
Contributor Author

Bump, this is critical for me, anyone could reproduce it?

@vladfaust
Copy link
Contributor Author

Really

@faustinoaq faustinoaq added the bug label Apr 6, 2018
@faustinoaq faustinoaq added this to To do in Crystal Tools via automation Apr 6, 2018
@faustinoaq
Copy link
Member

@vladfaust Sorry for the late response, I'm organizing the issues and PRs to track them easily 😅

Check https://github.com/orgs/crystal-lang-tools/projects/1?fullscreen=true 😉

@vladfaust
Copy link
Contributor Author

@fgimian I would be happy if you could help me with that 😢

@fgimian
Copy link
Contributor

fgimian commented Jun 24, 2018

Yep, I can reproduce it as follows.

Ensure that auto_format is enabled (this is enabled by default in the Crystal Sublime extension). Then once saving the file:

Traceback (most recent call last):
  File "./python3.3/json/decoder.py", line 367, in raw_decode
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 1072, in run_
    return self.run(edit)
  File "/Users/fots/Library/Application Support/Sublime Text 3/Installed Packages/Crystal.sublime-package/crystal_format.py", line 52, in run
  File "./python3.3/json/__init__.py", line 316, in loads
  File "./python3.3/json/decoder.py", line 351, in decode
  File "./python3.3/json/decoder.py", line 369, in raw_decode
ValueError: No JSON object could be decoded

I'm sure we can fix this quite easily. I personally don't like auto_format to be enabled, especially by default, and thus I disable it myself so I've never noticed this problem.

If I get a little spare time, I'll try to assist with a fix for this extension.

Cheers
Fotis

@fgimian
Copy link
Contributor

fgimian commented Jun 24, 2018

The problem is simply that there's no exception handling in https://github.com/crystal-lang-tools/sublime-crystal/blob/master/crystal_format.py if things go wrong.

Cheers
Fotis

@vladfaust vladfaust changed the title Crystal 0.24.1 broke errors handling Formatting errors aren't properly handled when auto_format is enabled Jun 25, 2018
@fgimian
Copy link
Contributor

fgimian commented Jun 26, 2018

I'll be sending a pull request that fixes this in a sec guys 😄

hovsater added a commit that referenced this issue Oct 2, 2018
Corrected handling of invalid source code when auto formatting (fixes #32)
Crystal Tools automation moved this from To do to Done Oct 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Crystal Tools
  
Done
Development

No branches or pull requests

3 participants