Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

CommandNotFoundError is rescued and added to model errors #1352

Closed
adamniedzielski opened this issue Sep 29, 2013 · 5 comments
Closed

CommandNotFoundError is rescued and added to model errors #1352

adamniedzielski opened this issue Sep 29, 2013 · 5 comments

Comments

@adamniedzielski
Copy link
Contributor

I spent some time debugging when I pushed the code to my CI server and one spec was failing. The spec was a Capybara feature which was submitting form with attachment and checking if the model got saved. Finally I found the error among validation errors - it was CommandNotFoundError - "Could not run the identify command. Please install ImageMagick."

This was quite surprising, because it is a missing dependency and certainly not validation error. I cannot imagine a case when I want to present it to the end-user.

Looking through the code I found the reason of this behaviour:

https://github.com/thoughtbot/paperclip/blob/adddf87cf30d416d71c7b2a80a004d170d10dc2c/lib/paperclip/attachment.rb#L434-437

In this case I would expect that the exception is not rescued at all because it is a matter of overlooked dependency and should be clearly visible. Visible to the dev, not the user.

What do you think?

@maclover7
Copy link
Contributor

Hi @adamniedzielski ! Is this still an issue for you in Paperclip; I know this issue is from approximately 2 years ago. If it is still an issue, can you please provide the code that's causing you the error? Thanks!

@adamniedzielski
Copy link
Contributor Author

@maclover7
Copy link
Contributor

How would you like to see errors resolved - feel free to send in a PR with your approach to solve the problem.

@adamniedzielski
Copy link
Contributor Author

After looking at exceptions inheriting from Paperclip::Error, I think that there is only one which should be rescued and go to the end user - NotIdentifiedByImageMagickError. All others are programmer's errors and should not be rescued. What do you think about it?

@maclover7
Copy link
Contributor

Sounds fine to me. Would you be willing to send in a PR?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants