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

collect and propogate loader errors #46

Merged
merged 2 commits into from Feb 25, 2020

Conversation

jbeeko
Copy link
Contributor

@jbeeko jbeeko commented Feb 24, 2020

Currently if a generator operates over invalid page data it is not able to express this in a nice way. For example if a post.md file is missing title in the top matter this is the result:

An unexpected error happend: Exception has been thrown by the target of an invocation.
... more useless logging which tells you nothing

To see this happen simply add a new file to the /posts director while in watch mode. The result is an immediate exception and termination of watch mode.

My first thought was to catch the invocation exception and indicate which page is failing during the load/generation phase.

That results in this:

The expression for /Users/joergbeekmann/Documents/Fornax/FornaxDemo/generators/post.fsx either couldn't be compiled or experianced a runtime
[11:34:23] '/Users/joergbeekmann/Documents/Fornax/FornaxDemo/_public/posts/post2.html' generation failed

Better, at least you know which page it is. But there is no way for the generator to indicate what is wrong with the markdown on the page. In this case a missing title.

This PR explores how to collect errors that occur during the load phase and then surface them as notifications in the console. That results in the following:

[10:03:28] Watch mode started. Press any key to exit.
[10:03:28 INF] Smooth! Suave listener started in 35.71ms with binding 127.0.0.1:8080
[10:03:44] Changes detected: /Users/joergbeekmann/Documents/FornexDemo/posts/post3.md
BAD FILE: /Users/joergbeekmann/Documents/FornexDemo/posts/post3.md
[10:03:44] '/Users/joergbeekmann/Documents/FornexDemo/_public/index.html' generated in 161ms
[10:03:44] '/Users/joergbeekmann/Documents/FornexDemo/_public/about.html' generated in 126ms

This PR is a proof of concept to go with issue #44.

@Krzysztof-Cieslak Krzysztof-Cieslak merged commit b82fd23 into ionide:master Feb 25, 2020
@Krzysztof-Cieslak
Copy link
Member

I like it, thanks!

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

Successfully merging this pull request may close these issues.

None yet

2 participants