RAILS 6从失败的单元结果获取错误消息

发布于 2025-01-30 09:29:15 字数 263 浏览 2 评论 0原文

是否有可能收到作为失败单元结果传递的错误消息?据我所见,为提供了方法成功> ,但是否也可以从失败中获取消息?

response[0]
=> Failure("12345 - Product code is not valid")

像:

response[0].message
=> "12345 - Product code is not valid"

Is it possible to get error message which was passed as a Failure monad result? as far as I can see the value! method is provided for Success but is it possible to get message from Failure as well?

response[0]
=> Failure("12345 - Product code is not valid")

to be something like:

response[0].message
=> "12345 - Product code is not valid"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

秋凉 2025-02-06 09:29:15

要访问失败消息失败monad提供失败方法。

response[0].failure
=> "12345 - Product code is not valid"

To access the Failure message Failure monad provides failure method.

response[0].failure
=> "12345 - Product code is not valid"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文