How to raise HTTP error in rails?

Hello, I have to handle this exception: HTTP 502: Response body: Got
EOF
while waiting for outstanding responses (Koala::Facebook::APIError)

and I have written this test:
it “should handle Koala’s error” do
get :test_action
response.should redirect_to root_url
flash[:alert].should == “HTTP 502: Response body: Got EOF while
waiting for outstanding responses (Koala::Facebook::APIError)”
end

The file in which is used graph.batch is in lib folder and since I can’t
use things like redirect_to or something else in these files I decided
to
handle this error writing rescue block in ApplicationController:

 rescue_from Koala::Facebook::APIError do |exception|
    redirect_to root_url, :alert => exception.message
end

But then I though that maybe I should handle 502 error and in that case
I
only have to write 502.html file in public folder. Right?
Can someone help me with the right path to handle this error. Thanks in
advance :slight_smile:

On Wednesday, July 25, 2012 7:19:38 PM UTC+1, Tsvetelina B. wrote:

only have to write 502.html file in public folder. Right?
Can someone help me with the right path to handle this error. Thanks in
advance :slight_smile:

It doesn’t look like there is a 502 error for you to handle directly -
Koala has wrapped that up inside a Koala::Facebook::APIError. Rescuing
at
the controller with rescue_from sounds reasonable to me

Fred