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

Show meaningful error message on missing file #2360

Closed
JoaquimLey opened this issue Sep 8, 2020 · 3 comments · Fixed by #3178
Closed

Show meaningful error message on missing file #2360

JoaquimLey opened this issue Sep 8, 2020 · 3 comments · Fixed by #3178

Comments

@JoaquimLey
Copy link

JoaquimLey commented Sep 8, 2020

What are you trying to achieve?
I have the following sequence using sharp

const result = await sharp(inputBuffer)
        .resize(460)
        .composite([{ input: watermark, gravity: 'center' }])
        .toFormat('webp', { quality: 90 })
        .toBuffer();

Everything should work as expected, the issue is:

  • I've actually moved the current file where this processing takes place, therefore the watermark input file has a different path.
  • One could argue I should use fully qualified paths but the issue I have is with the error message
Error: Input file is missing

I Found it super strange as this used to work just fine, but outputting this generic error got me through a google+stackoverflow+this-repo-issues rabbit hole thinking it was actually an issue with the inputBuffer.

Suggestion

A better output would be

Error: Could not <composite|process|etc> Input file at <provided path> is missing
@lovell
Copy link
Owner

lovell commented Sep 9, 2020

Hi, thanks for the suggestion.

The error message originates from:

throw vips::VError("Input file is missing");

The InputDescriptor passed to the OpenInput function would need some form of (string?) context to be able to add more details to this error message.

Happy to accept a PR if you're able.

@Brodan
Copy link
Contributor

Brodan commented Apr 2, 2022

Seconding the need for this. I'm currently using sharp to composite 20+ layers of images so it's a massive pain to figure out which input file is missing when this error message doesn't tell me.

I've not written almost any cpp code but I could take a crack at a PR. It seemed like it would be any easy fix but the response above leads me to believe that it actually isn't. I'll see what I can do.

@lovell
Copy link
Owner

lovell commented Apr 18, 2022

v0.30.4 now available, thanks for the PR.

@lovell lovell closed this as completed Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants