class Twitter::BadGatewayError

Runtime error leaf class raised when Twitter.com servers are being upgraded. HTTP code: 502 (aka Bad Gateway).

To handle specifically you would do the following:

begin
  timeline = twitter.timeline_for(:friends, :since => tweet)
rescue BadGatewayError => bge
  #
end