Error handling with command calls

Hello,

I’m trying to rewrite a Bash shell script with Ruby.

do_something
if $?.exitstatus != 0
handle_error
end

do_some_other_thing
if $?.exitstatus != 0
handle_error
end

How can I avoid having to poll exitstatus after every command call? I’m
looking for something to replace bash’s trap.

Stefan

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs