Error handling in Ruby scripts



Hi,
Can someone please help me with exception handling? I've written some
classes and scripts that I've used for a year or two. But now, I'm
having to use them with many thousands of files at once, and, even
though they process just one file at a time, there are sometimes errors
in the tools that I use. Specifically, I use an image processing tool
called Image Alchemy. In my Ruby scripts, I have a class written that
has in it various conversion routines where it converts the file pointed
to in Ruby to various formats--TIFF, PNG, etc., etc. My problem is that
when I'm presented with many thousands of files, I'm getting the odd
input file that's just bad. So, my Alchemy Ruby code fails, because
Alchemy itself is failing with that bad file. So, I've read a bit about
"raise," but, I can't seem to get it to work. Can I use "raise" as an
exception handler in my class? Then, in my scripts, could I use
"begin/rescue" with that exception?

Below is a subset of my class

Thanks,
Peter

class Alchemy
def initialize(file)
@file = file
end
def Alchemy.tiff(file)
`alchemy #{file} -t1 -Zc1 -Zm2 -Za4 -Zd 300 300 .300 -o`
end
def Alchemy.tiffbw(file)
`alchemy #{file} -t204 -Zc1 -Zm2 -Za4 -Zd 600 600 .300 -o`
end
def Alchemy.tiffgray(file)
`alchemy #{file} -t1 -Zc1 -Zm2 -b -c256 -8 -Za4 -Zd 300 300 .300 -o`
end
end
--
Posted via http://www.ruby-forum.com/.

.



Relevant Pages

  • Re: Error handling in Ruby scripts
    ... Can someone please help me with exception handling? ... classes and scripts that I've used for a year or two. ...   def initialize ...   def Alchemy.tiff ...
    (comp.lang.ruby)
  • Re: itertools.flatten()? and copying generators/iterators.
    ... def flatten_po: ... 100 loops, best of 3: ... I fully expected pro_am to be slower, ... BUT only at the cost of an exception. ...
    (comp.lang.python)
  • Re: The ducks backside
    ... then a runtime exception will be thrown. ... def initialize(_a, _b, _c) ... # parameter of of the wrong static type. ... def static_type_check(klass) ...
    (comp.lang.ruby)
  • Cant set attribute?!
    ... and i don't understand why following exception ... def login: ... args = + args ... sock.connect(host, port) ...
    (comp.lang.python)
  • A file for making scripts for Dragonfly
    ... def _process_recognition: ... },#application-specific scripts ...
    (comp.lang.beta)