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