开发者

return a FaultObject on purpose from pyamf

开发者 https://www.devze.com 2022-12-12 06:08 出处:网络
I am currently migrating fro开发者_C百科m RubyAMF to PyAMF.In RubyAMF you can return a FaultObject deliberately like so:

I am currently migrating fro开发者_C百科m RubyAMF to PyAMF. In RubyAMF you can return a FaultObject deliberately like so:

render :amf => FaultObject.new("Thats not your pie!")

Is there comparable functionality in PyAMF? I've searched the docs and can't find any mention of it.


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!')


raise Exception, "ur message" can do.

0

精彩评论

暂无评论...
验证码 换一张
取 消