我目前正在从 RubyAMF 迁移到 PyAMF。在 RubyAMF 中,您可以像这样故意返回一个 FaultObject:
render :amf => FaultObject.new("Thats not your pie!")
PyAMF 中是否有类似的功能?我已经搜索了文档,但找不到任何提及它的内容。
我目前正在从 RubyAMF 迁移到 PyAMF。在 RubyAMF 中,您可以像这样故意返回一个 FaultObject:
render :amf => FaultObject.new("Thats not your pie!")
PyAMF 中是否有类似的功能?我已经搜索了文档,但找不到任何提及它的内容。
coulix is right (but due to reputation restrictions I cannot upvote! :)
From within your service method, raise an exception as you would normally and PyAMF will trap that and convert it to an appropriate fault object for consumption by the requestor (e.g. using Flex Messaging this will be an ErrorMessage instance).
class HandsOffThatPie(Exception):
pass
def get_pie(please=False):
if not please:
raise HandsOffThatPie('Say please!')
引发异常,“你的消息”可以做到。