-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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 IO errors when writing media files, closes #4559 #4619
Conversation
@danse You need to fix the warning. See Travis CI output. |
oops thanks for the heads up @wilx i fixed it let's wait for the new build |
Under these conditions, will we still get a CouldNotFetchResource warning, or just the IgnoredIOError? I think it would be best if we still got CouldNotFetchResource as well. |
Yes we still get the warning which is triggered by an independent part of the software, within
|
the warning is triggered when the resource is not found. but then the ODT reader fetches the resource independently and stores an empty path in the media bag. when we try to use the path later on we get the error that is ignored in this change |
OK, good. I'm still not sure what I think about this, though.
One could make a case for the view that this is a bug in pandoc,
and should therefore lead to an error rather than a warning.
Pandoc should handle this case better.
Francesco Occhipinti <notifications@github.com> writes:
… Yes we still get the warning which is triggered by an independent part of the software, within `fetchMediaResource` if i remember correctly. Using the test file from #4559, the output with this change is the following
```
[WARNING] Could not fetch resource './ObjectReplacements/Object 1': replacing image with description
[WARNING] IO Error (ignored): media/.: openBinaryFile: inappropriate type (Is a directory)
```
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#4619 (comment)
|
On reflection, not all IO errors will be pandoc bugs (a file might not have the right permissions, e.g.), so let's do this. |
res <- liftIO $ tryIOError f | ||
case res of | ||
Left e -> report $ IgnoredIOError (E.displayException e) | ||
Right _ -> pure () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not change type to IO a -> PandocIO a
and change this line to
Right x -> return x
That makes the function more general.
Either that, or change the type to IO () -> PandocIO ()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IO a -> Pandoc a
would require a default value when the operation fails, so i opted for IO () -> Pandoc ()
, i amended and rebased
if we do not catch these errors, any malformed entry in a media bag could cause the loss of a whole document output. an example of malformed entry is an entry with an empty file path
I agree that this is a fault in pandoc, yet the conversion process can continue. Why would we want a fault to be fatal, rather than preserving what is unaffected? We could rename |
if we do not catch these errors, any malformed entry in a media bag
could cause the loss of a whole document output. an example of
malformed entry is an entry with an empty file path.
for the error logging i looked for a way to preserve information from the IO error. An IO error like
media/.: openBinaryFile: inappropriate type (Is a directory)
can give helpful troubleshooting information to the users in case of errors in a path or problems with permission