Ticket #258 (closed defect: fixed)

Opened 8 months ago

Last modified 7 months ago

Traceback with amfphp and Exceptions

Reported by: wic Owned by: feisley
Priority: major Milestone: 0.3.1
Component: Remoting Version: 0.3
Keywords: review Cc: wic@…

Description

When calling a amfphp service which throws an Exception, I get this error stack:

Traceback (most recent call last):
  File "/home/wic/client.py", line 48, in ?
    installRPC(appkey, newname, customer, dpp);
  File "build/bdist.linux-i686/egg/pyamf/remoting/client/__init__.py", line 110, in __call__
  File "build/bdist.linux-i686/egg/pyamf/remoting/client/__init__.py", line 99, in _call
  File "build/bdist.linux-i686/egg/pyamf/remoting/client/__init__.py", line 337, in execute_single
  File "build/bdist.linux-i686/egg/pyamf/remoting/client/__init__.py", line 398, in _getResponse
  File "build/bdist.linux-i686/egg/pyamf/remoting/__init__.py", line 542, in decode
  File "build/bdist.linux-i686/egg/pyamf/remoting/__init__.py", line 394, in _read_body
  File "build/bdist.linux-i686/egg/pyamf/remoting/__init__.py", line 489, in get_fault
TypeError: __init__() got an unexpected keyword argument 'line'

The "offending" php code is

throw new Exception ("The error message");

For the record, this works in Flex 3. Ie the flash application pop up a messagebox which displays "The error message".

Attachments

kwargs-258.diff (0.7 KB) - added by nick 8 months ago.
kwargs-258.2.diff (0.7 KB) - added by nick 8 months ago.
Updated patch
test-258.py (293 bytes) - added by thijs 7 months ago.
test file for amfphp exceptions

Change History

Changed 8 months ago by wic

Is it possible to ask pyamf for the (binary) amf-data returned from the service? That could help debugging this I guess

Changed 8 months ago by nick

Try this:

import logging

from pyamf.remoting.client import RemotingService

# setup the gateway here
gw = RemotingService('http://url/path/to/gateway')

gw.logger.setLevel(logging.DEBUG)

service = gw.getService('badMethod')

service()

Thats sets the logger to be as verbose as possible and should shed some more light on the problem.

Do you have a public gateway url that I could use to check up on the problem?

Changed 8 months ago by nick

  • owner changed from nick to wic
  • status changed from new to assigned
  • component changed from AMF3 to AMF0

Can you apply the attached diff and let me know if you have better mileage?

Changed 8 months ago by nick

Changed 8 months ago by nick

  • component changed from AMF0 to Remoting

Changed 8 months ago by wic

I tried the patch, but it gives me NameError: global name 'kwargs' is not defined. The DEBUG setting did not give anything really useful.

I'm working on getting an external gateway up for you to test. I'll be back in a few...

Changed 8 months ago by wic

Ok, try this. Two services, one which throws and one which dont.

from pyamf.remoting.client import RemotingService

url="http://lara.xms.se:80/amfphptest/amfphp/gateway.php"

gateway = RemotingService(url)
#service = gateway.getService('Service.dontThrowException')
service = gateway.getService('Service.throwException')
msg = service("mymessage")
print msg

There is a flash browser here whic shows more details: http://lara.xms.se/amfphptest/amfphp/browser/

Changed 8 months ago by nick

Updated patch

Changed 8 months ago by nick

okay, using the updated patch i get:

<BaseFault level=None code=AMFPHP_RUNTIME_ERROR description=Testexception: mymessage>

Changed 8 months ago by thijs

  • summary changed from BackTrace when with amfphp and Exceptions to Traceback with with amfphp and Exceptions

Changed 8 months ago by thijs

  • summary changed from Traceback with with amfphp and Exceptions to Traceback with amfphp and Exceptions

meh

Changed 8 months ago by wic

Yup, that seems to work.

By the way, what is the correct way for me to handle errors like this? Am I supposed to check the returned object somehow:

service = gateway.getService('Service.throwException')
msg = service("mymessage")
if msg.code == "AMFPHP_RUNTIME_ERROR":
    print "error!"

Or maybe a typecheck if msg is a BaseFault?

Changed 8 months ago by nick

As a stop gap, checking isinstance(msg, BaseFault) is the way to go. I would suggest that service("mymessage") should raise an error if the remoting status is remoting.STATUS_ERROR.

I'll create a ticket for that.

Changed 8 months ago by nick

See #260.

Changed 8 months ago by nick

  • keywords review added
  • owner changed from wic to feisley

Changed 7 months ago by thijs

Ran 418 tests in 0.775s

PASSED (successes=418)

Changed 7 months ago by thijs

test file for amfphp exceptions

Changed 7 months ago by thijs

Looks good with attached test-258.py:

<BaseFault level=None code=AMFPHP_RUNTIME_ERROR description=Testexception: mymessage>

Changed 7 months ago by wic

Looks fine. Is it supposed to be included in the next pyamf release?

Changed 7 months ago by nick

  • status changed from assigned to closed
  • resolution set to fixed

Merged to trunk in r1277.

wic: Thats right :) 0.3.1 coming up v soon.

Note: See TracTickets for help on using tickets.