title: How would I get an error to display with this controller/model setup?
body: <p>I have a create method that calls a method in a model that pings some third-party APIs.</p>
  
  <p>What I need to do is if the API sends back a certain message, then I'd display an error.</p>
  
  <p>Below is my current controller and model setup, so how would I get the error back in to the controller (and ultimately the view)?</p>
  
  <p>Here is the method in my controller:</p>
  
  <pre><code>def create
    @number = Number.where(:tracking =&gt; params[:number][:tracking], :user_id =&gt; current_user.id).first
  
    if @number.blank?
      @number = Number.new
      @number.tracking = params[:number][:tracking]
      @number.user_id = current_user.id
      @number.notes = params[:number][:notes]
      @number.track
    end
  
    respond_with(@number) do |format|  
      format.html { redirect_to root_path }  
    end
  end
  </code></pre>
  
  <p>Here are the methods in my model:</p>
  
  <pre><code>def track
    create_events
  end
  
  
  def create_events(&amp;block)
  
    tracker = fedex.track(:tracking_number =&gt; number)
  
    if tracker.valid?    
      self.assign_tracker(tracker)
  
      tracker.events.each do |e|
        self.create_event(e) unless (block_given? &amp;&amp; !block.call(e))
      end
  
      save
    else
      # NEED TO THROW THE ERROR HERE
    end
  end
  </code></pre>