title: How would one make multiple exception classes inherit from one parent class?
body: <p>So far I have this...</p>
  
  <pre><code>class MembersController &lt; ApplicationController
  
    rescue_from Mailchimp::Exception::DataException,
      Mailchimp::Exception::APIKeyError,
      Mailchimp::Exception::NotFound,
      Mailchimp::Exception::Duplicate,
      Mailchimp::Exception::MissingField,
      Mailchimp::Exception::BadRequest,
      Mailchimp::Exception::UnknownAttribute,
      Mailchimp::Exception::MissingId,
      with: :error
  
    def error(e)
  
      puts 'Message: ' + e.message
      puts 'Type: ' + e.type
      puts 'Title: ' + e.title
  
      e.errors.each do |error|
        puts 'Field: ' + error['field']
        puts 'Message: ' + error['message']
      end if e.errors
  
      # Respond to the HTTP POST request by passing the errors
      return render_with(500, e.message, e.errors)
  
    end
  
    private
  
    def render_with(status_code, message, errors='none')
  
      if errors == 'none'
        status = 'success'
        success = true
      else
        status = 'error'
        success = false
      end
  
      render json: {
        :status =&gt; status,
        :success =&gt; success,
        :message =&gt; message,
        :errors =&gt; errors,
        :params =&gt; params.as_json
      },
      status: status_code
  
    end
  
  end
  </code></pre>
  
  <p>In an attempt to make it DRY, I have done this...</p>
  
  <pre><code>class MembersController &lt; ApplicationController
  
    mailchimpExceptions = [
      'DataException',
      'APIKeyError',
      'NotFound',
      'Duplicate',
      'MissingField',
      'BadRequest',
      'UnknownAttribute',
      'MissingId'
    ]
  
    exceptions = Array.new
  
    mailchimpExceptions.each do |exception|
      exceptions &lt;&lt; "Mailchimp::Exception::#{exception}"
    end
  
    rescue_from *exceptions, with: :error
  
    def error(e)
  
      puts 'Message: ' + e.message
      puts 'Type: ' + e.type
      puts 'Title: ' + e.title
  
      e.errors.each do |error|
        puts 'Field: ' + error['field']
        puts 'Message: ' + error['message']
      end if e.errors
  
      # Respond to the HTTP POST request by passing the errors
      return render_with(500, e.message, e.errors)
  
    end
  
    private
  
    def render_with(status_code, message, errors='none')
  
      if errors == 'none'
        status = 'success'
        success = true
      else
        status = 'error'
        success = false
      end
  
      render json: {
        :status =&gt; status,
        :success =&gt; success,
        :message =&gt; message,
        :errors =&gt; errors,
        :params =&gt; params.as_json
      },
      status: status_code
  
    end
  
  end
  </code></pre>
  
  <p>I am wondering if all the exceptions could by under one class, so that only one class is called like <code>rescue_from MailchimpExceptions, with: :error</code>. <a href="https://stackoverflow.com/a/30835861/1298155">This answer by mgolubitsky</a> suggests it is possible, but I have no idea how to go about it.</p>
  
  <p>I am using gem 'mailchimp_api_v3'.</p>