【问题标题】:Twitter API: How do I catch when Twitter's API is down?Twitter API:当 Twitter 的 API 出现故障时,我如何捕捉?
【发布时间】:2013-06-04 04:46:28
【问题描述】:

我的网站上有一个简单的“最新推文”部分。它使用 Twitter Gem 并调用 Twitter API 来获取最新的 2 条推文,然后将它们放到页面上。

现在,Twitter 的 API 已关闭,我的网站正在抛出 Twitter::Error::DecodeError。我该如何计算这样的时间并妥善处理?

【问题讨论】:

    标签: ruby-on-rails twitter


    【解决方案1】:
    begin
      # twitter api call stuff here
    rescue Twitter::Error::DecodeError => e
      # stuff you want to make happen then the error is raised i.E.
      Airbrake.notify_or_ignore(e, :parameters => params, :session_data => session)
      # optional raise the error after the catch to handle it elsethere or if you want it to raise
      raise e 
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-02
      • 1970-01-01
      • 2012-07-19
      • 2012-11-26
      • 2020-07-09
      • 1970-01-01
      • 2014-12-27
      • 2013-12-13
      相关资源
      最近更新 更多