title: How to write an exception for nil or empty string in Ruby
body: <p>Started learning Ruby a week ago. The most frustrating part so far has been exception handling. Been looking for an example for what I want to do for hours.</p>
  
  <p>I am looping through an array of API codes, grabbing text via Net::Http. Sometimes the grab returns nil or empty, and I'm trying to test for it in a way that will let me retry the grab on that exception until it works.</p>
  
  <p>I am fairly certain I need to do something like</p>
  
  <pre><code>array.each do |api_key|
    begin
     result = # the code to grab the page via the API key
  
     if result.empty or result.nil
       raise SomeKindOfExceptionThing
     end
  
    rescue SomeKindOfExceptionThing
      puts "some error message"
      retry
  
    else
      # Act on the valid return for result
    end
  end
  </code></pre>
  
  <p>I have no idea how to properly form this so it does what I want. Most of the documentation I've found on exceptions is for handling predefined types of errors or just a generic <code>rescue</code>.</p>