# Raising errors in plugin-files or UploadColumn Validation

**URL:** <https://www.ruby-forum.com/t/raising-errors-in-plugin-files-or-uploadcolumn-validation/112507>\
**Category:** Rails\
**Created:** [August 20, 2007, 12:37pm UTC](https://www.ruby-forum.com/t/raising-errors-in-plugin-files-or-uploadcolumn-validation/112507 "2007-08-20T12:37:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bluescript](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/59ef9b/32.png) [@bluescript](https://www.ruby-forum.com/u/bluescript)\
**Post date:** [August 20, 2007, 12:37pm UTC](https://www.ruby-forum.com/t/raising-errors-in-plugin-files-or-uploadcolumn-validation/112507/1 "2007-08-20T12:37:31Z")

</div>

Hi all!

I have a problem with the validation of uploaded images, or, to be more  
specific, with raising errors from plug-in files. I am using  
UploadColumn to upload pictures. Problem is that it won’t raise errors  
when upload e.g. txt-files. It will say “Upload succesfull”, the  
time-stamp is updated only the picture hasn’t changed.

I looked through the code of the plugin and found:

#----File: upload\_column.rb  
#----Code  
[begin]--------------------------------------------------------------------------------------------------------------------------------------  
# Note also that unlike RMagicks’s read, this method will return nil  
if the image cannot  
# be opened, it will not throw an Error, so you can happily  
# apply this, even if you aren’t sure that the file is an image.  
#  
# +process!+ is usually more useful, don’t use +procesrs+ unless  
there is a good reason to!  
#  
# Remember to call GC.start after you are done processing the image,  
to avoid memory leaks.  
def process  
# Load the file as a ImageMagick object, pass to block, return the  
yielded result  
begin  
img = ::Magick::Image::read(self.path).first  
rescue Magick::ImageMagickError  
return nil  
end  
yield( img )  
end  
#----Code  
[end]----------------------------------------------------------------------------------------------------------------------------------------

Now I guess Iâ€™d just have to raise an error message substituting â€œreturn  
nilâ€. Is that right? If so, how can I do that? I experimented a bit  
around but with no success.

Hope you can help me! Big thanks in advance!

bluescript
