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

Dump all the errors from different files #56

Closed
alyoanton9 opened this issue Feb 8, 2021 · 3 comments · Fixed by #141
Closed

Dump all the errors from different files #56

alyoanton9 opened this issue Feb 8, 2021 · 3 comments · Fixed by #141
Assignees
Labels
improvement Updates existing functionality
Milestone

Comments

@alyoanton9
Copy link
Contributor

Clarification and motivation

As we have right in-place annotations now (<!-- xrefcheck: ignore <mode>-->), there can be broken markdowns.
For example:

  1. <!-- xrefcheck: ignore file--> located in the "middle" of the file (not right after the comments at the top) causes Error when scanning .\markdowns\with-annotations\no_paragraph.md: expected a PARAGRAPH after "ignore paragraph", but found HEADING (9:1-17).
  2. A typo like <!-- xrefcheck: ignore ile --> causes Error when scanning .\markdowns\with-annotations\unexpected_ignore_file.md: unrecognised option " "ignore ile" perhaps you meant <"ignore link"|"ignore paragraph"|"ignore file"> ( 9:1 - 8:0)
    And so on.

Currently, xrefcheck fails immediately after the first observed error because die is used right in markdownScanner:

markdownScanner path = do
    errOrInfo <- parseFileInfo . decodeUtf8 <$> BSL.readFile path
    case errOrInfo of
        Left errTxt -> do
            die $ "Error when scanning " <> path <> ": " <> T.unpack errTxt
        Right fileInfo -> return fileInfo

And propagated on a higher level, to Main.
What we want is dumping all the errors from different markdowns and then print them as a final xrefcheck's result together with the broken links.
A possible solution is to add a custom exception type for scanner errors, this way exceptions can be reasonably caught outside if necessary (not in inner components).

Acceptance criteria

  1. No die in inner components.
  2. All the errors are printed as a result together with the broken links.
@Martoon-00 Martoon-00 added the improvement Updates existing functionality label Aug 25, 2021
@dcastro dcastro assigned Sereja313 and unassigned worm2fed Sep 4, 2022
@dcastro
Copy link
Member

dcastro commented Sep 4, 2022

@Sereja313: Andrii had previously started working on this issue. He had a Draft PR (see #87). I'm not sure how close to completion it was - can you please have a look at the PR?

Let me know what you think of the PR, and whether you think it's best to just continue working on that branch (it's been a while, rebasing that branch might lead to lots of merge conflicts) or to start from scratch with your own approach.

@Sereja313
Copy link
Member

Sereja313 commented Sep 7, 2022

@dcastro, It looks like not much has been done, so I started from scratch to avoid merge conflicts.

@dcastro
Copy link
Member

dcastro commented Sep 8, 2022

@Sereja313 Sounds good! 👍

@dcastro dcastro added this to the 0.2.1 milestone Sep 9, 2022
Sereja313 added a commit that referenced this issue Sep 13, 2022
Problem: Currently, xrefcheck fails immediately after the first
observed error because `die` is used right in `markdownScanner` What
we want is dumping all the errors from different markdowns and then
print them as a final xrefcheck's result together with the broken
links. Also, despite the fact that in the `makeError` function we have
4 error messages, 2 of them are not reported, and the test case that
should check this only checks that at least one of the four files
throws an error.

Solution: Make xrefcheck to report all errors. Add `ScanError` type
and propagate errors to report all of them, rather than failing
immediately after the first error is detected.
Sereja313 added a commit that referenced this issue Sep 22, 2022
Problem: Currently, xrefcheck fails immediately after the first
observed error because `die` is used right in `markdownScanner` What
we want is dumping all the errors from different markdowns and then
print them as a final xrefcheck's result together with the broken
links. Also, despite the fact that in the `makeError` function we have
4 error messages, 2 of them are not reported, and the test case that
should check this only checks that at least one of the four files
throws an error.

Solution: Make xrefcheck to report all errors. Add `ScanError` type
and propagate errors to report all of them, rather than failing
immediately after the first error is detected.
Sereja313 added a commit that referenced this issue Sep 23, 2022
Problem: Currently, xrefcheck fails immediately after the first
observed error because `die` is used right in `markdownScanner` What
we want is dumping all the errors from different markdowns and then
print them as a final xrefcheck's result together with the broken
links. Also, despite the fact that in the `makeError` function we have
4 error messages, 2 of them are not reported, and the test case that
should check this only checks that at least one of the four files
throws an error.

Solution: Make xrefcheck to report all errors. Add `ScanError` type
and propagate errors to report all of them, rather than failing
immediately after the first error is detected.
Sereja313 added a commit that referenced this issue Sep 23, 2022
…rom-files

[#56] Dump all the errors from different files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Updates existing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants