Skip to content
This repository was archived by the owner on Oct 1, 2019. It is now read-only.

Throw python exec spawnSync errors #99

Merged
merged 1 commit into from
May 21, 2018

Conversation

ryanashcraft
Copy link
Collaborator

To reduce confusion when the requested python executable is not in your PATH or some other possible errors from executing python. See #98.

Before w/ confusing TypeError:

➜  plugin-python git:(spawn-error) ✗ ./node_modules/.bin/prettier  --plugin=. --parser=python ./tests/python_assert/assert.py

[error] tests/python_assert/assert.py: TypeError: Cannot read property 'toString' of null
[error]     at parseText (/mnt/c/Users/Ryan/Documents/Code/plugin-python/src/parser.js:15:39)
[error]     at Object.parse (/mnt/c/Users/Ryan/Documents/Code/plugin-python/src/parser.js:26:27)
[error]     at Object.parse (/mnt/c/Users/Ryan/Documents/Code/plugin-python/node_modules/prettier/src/main/parser.js:75:19)
[error]     at formatWithCursor (/mnt/c/Users/Ryan/Documents/Code/plugin-python/node_modules/prettier/index.js:101:25)
[error]     at Object.formatWithCursor (/mnt/c/Users/Ryan/Documents/Code/plugin-python/node_modules/prettier/index.js:402:12)
[error]     at format (/mnt/c/Users/Ryan/Documents/Code/plugin-python/node_modules/prettier/src/cli/util.js:157:19)
[error]     at error (/mnt/c/Users/Ryan/Documents/Code/plugin-python/node_modules/prettier/src/cli/util.js:380:16)
[error]     at filePaths.forEach.filePath (/mnt/c/Users/Ryan/Documents/Code/plugin-python/node_modules/prettier/src/cli/util.js:322:7)
[error]     at Array.forEach (native)
[error]     at eachFilename (/mnt/c/Users/Ryan/Documents/Code/plugin-python/node_modules/prettier/src/cli/util.js:321:15)
[error]     at Object.formatFiles (/mnt/c/Users/Ryan/Documents/Code/plugin-python/node_modules/prettier/src/cli/util.js:338:3)
[error]     at Object.run (/mnt/c/Users/Ryan/Documents/Code/plugin-python/node_modules/prettier/src/cli/index.js:60:12)
[error]     at Object.<anonymous> (/mnt/c/Users/Ryan/Documents/Code/plugin-python/node_modules/prettier/bin/prettier.js:5:23)
[error]     at Module._compile (module.js:570:32)
[error]     at Object.Module._extensions..js (module.js:579:10)
[error]     at Module.load (module.js:487:32)

After with this change:

➜  plugin-python git:(spawn-error) ./node_modules/.bin/prettier  --plugin=. --parser=python ./tests/python_assert/assert.py

[error] tests/python_assert/assert.py: Error: python3 was not found in your PATH
[error]     at parseText (/mnt/c/Users/Ryan/Documents/Code/plugin-python/src/parser.js:19:13)
[error]     at Object.parse (/mnt/c/Users/Ryan/Documents/Code/plugin-python/src/parser.js:36:27)
[error]     at Object.parse (/mnt/c/Users/Ryan/Documents/Code/plugin-python/node_modules/prettier/src/main/parser.js:75:19)
[error]     at formatWithCursor (/mnt/c/Users/Ryan/Documents/Code/plugin-python/node_modules/prettier/index.js:101:25)
[error]     at Object.formatWithCursor (/mnt/c/Users/Ryan/Documents/Code/plugin-python/node_modules/prettier/index.js:402:12)
[error]     at format (/mnt/c/Users/Ryan/Documents/Code/plugin-python/node_modules/prettier/src/cli/util.js:157:19)
[error]     at error (/mnt/c/Users/Ryan/Documents/Code/plugin-python/node_modules/prettier/src/cli/util.js:380:16)
[error]     at filePaths.forEach.filePath (/mnt/c/Users/Ryan/Documents/Code/plugin-python/node_modules/prettier/src/cli/util.js:322:7)
[error]     at Array.forEach (native)
[error]     at eachFilename (/mnt/c/Users/Ryan/Documents/Code/plugin-python/node_modules/prettier/src/cli/util.js:321:15)
[error]     at Object.formatFiles (/mnt/c/Users/Ryan/Documents/Code/plugin-python/node_modules/prettier/src/cli/util.js:338:3)
[error]     at Object.run (/mnt/c/Users/Ryan/Documents/Code/plugin-python/node_modules/prettier/src/cli/index.js:60:12)
[error]     at Object.<anonymous> (/mnt/c/Users/Ryan/Documents/Code/plugin-python/node_modules/prettier/bin/prettier.js:5:23)
[error]     at Module._compile (module.js:570:32)
[error]     at Object.Module._extensions..js (module.js:579:10)
[error]     at Module.load (module.js:487:32)

@patrick91 patrick91 merged commit 036c8a6 into prettier:master May 21, 2018
@patrick91
Copy link
Member

Good idea! thanks :)

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

Successfully merging this pull request may close these issues.

2 participants