2

我正在调用url_forgem 的方法aws-s3,它会抛出一个MissingCredentialsError < StandardError. url_for我怎样才能将它从被调用的类中拯救出来?我知道缺少凭据问题的解决方案,但我想知道如何处理异常。试过这个,没有运气:

begin
  ... code that get the error...
rescue MissingCredentialsError
  a = "THIS IS AN ERROR"
end

当我运行我的测试时,它会遇到这个错误:

ActionView::Template::Error: uninitialized constant Receipt::MissingCredentialsError
4

1 回答 1

3

捕获错误时更具体:

begin
  # code that get the error
rescue AWS::Errors::MissingCredentialsError => e
  # code that handles the exception
end
于 2013-10-03T15:02:18.727 回答