Ruby - how to raise same error for multiple methods without writing it multiple times?
<p>Lets say I create a Calculator class that works by manipulating elements in an array - within this class I define several methods: add, subtract, multiply, divide. I want each method to raise the same error if there exist only 1 or fewer elements in the array, something like:</p>

<pre><code>class Calculator
# ...
def add
  if @array.length &lt; 2
    raise 'Not Enough Elements'
  else
    @array &lt;&lt; @array.pop + @array.pop
  end
end
# ...
end
</code></pre>

<p>I could write a condition to raise the error into each method, but that seems very tedious and un-Ruby. Would there be a way to apply the raised error to all the methods that would need it that would save all that typing?</p>