gpt4 book ai didi

ruby-on-rails - 如何处理XMLRPC::FaultException errors?

转载 作者:行者123 更新时间:2023-12-03 09:00:08 25 4
gpt4 key购买 nike

我为每个帖子都提供了一个pingback列表。看起来像这样:

def send_trackback
#do stuff
begin
Pingback::Client.new.ping(source_uri, target_uri)
trackback.status = 1
trackback.save
rescue
trackback.status = 2
trackback.save
nil
end
end

这是完整的错误:
  XMLRPC::FaultException (The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.):
app/controllers/posts_controller.rb:67:in `block in send_trackback'
app/controllers/posts_controller.rb:62:in `send_trackback'
app/controllers/posts_controller.rb:8:in `pingback'

Rendered /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.1ms)
Rendered /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.8ms)
Rendered /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (4.6ms)

状态开始时为0,但是如果ping操作失败,则可以,但是我希望状态设置为2,并且我希望它继续前进,不会对Rails抛出错误。如果成功,我希望状态设置为1。

开始不应该-救援块可以解决这个问题吗?我想念什么?

最佳答案

那应该工作。看起来异常是在pingback/send_trackback中触发的,而不是send_pingback中触发的

关于ruby-on-rails - 如何处理XMLRPC::FaultException errors?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8460090/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com