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 and process possible exception on JSTransformer compileAsync and renderAsync #38

Merged
merged 2 commits into from
May 17, 2018
Merged

Catch and process possible exception on JSTransformer compileAsync and renderAsync #38

merged 2 commits into from
May 17, 2018

Conversation

ycherniavskyi
Copy link
Contributor

Similarly to problem resolved by #20, because of uncached exception of JSTransformer compileAsync and renderAsync functions, the real problem does not output to console:

[13:57:21] Starting 'content'...
[13:57:22] The following tasks did not complete: content
[13:57:22] Did you forget to signal async completion?

Process finished with exit code 0

After applying this pull request in output we get more useful information (and correct exit code):

[15:31:09] Starting 'content'...
[15:31:10] 'content' errored after 1.06 s
[15:31:10] Error: ENOENT: no such file or directory, open '/Users/ych/projects/test/src/projects/extension/_idea.md'
    at /Users/ych/projects/test/src/projects/extension/index.html.pug line 10
    at Object.fs.openSync (fs.js:667:18)
    at Object.fs.readFileSync (fs.js:572:33)
    at Function.read (/Users/ych/projects/test/node_modules/pug-load/index.js:69:13)
    at Object.read (/Users/ych/projects/test/node_modules/pug/lib/index.js:147:25)
    at /Users/ych/projects/test/node_modules/pug-load/index.js:24:25
    at walkAST (/Users/ych/projects/test/node_modules/pug-walk/index.js:23:18)
    at /Users/ych/projects/test/node_modules/pug-walk/index.js:104:20
    at Array.reduce (<anonymous>)
    at walkAndMergeNodes (/Users/ych/projects/test/node_modules/pug-walk/index.js:103:18)
    at walkAST (/Users/ych/projects/test/node_modules/pug-walk/index.js:37:19)

Process finished with exit code 1

This exception throw because of include:markdown-it _idea.md Including Plain Text construction in index.html.pug.

After some investigation of the reason that async function throw exception I found next line in jstransformer implementation. So yes, it seems jstransformer issue, but looking at the date of its last release and count of unresolved issues, I think it will be easy and faster to fix it here.

In future, if the issue of compileAsync and renderAsync methods will be fixed this try/catch blocks could be deleted.

@RobLoach
Copy link
Contributor

This is great! Thanks a lot. 👍

@RobLoach RobLoach merged commit fa892b3 into kalamuna:master May 17, 2018
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