Hi, i want to manage 2 type of Exception lightblue._obexcommon.OBEXError
1) lightblue._obexcommon.OBEXError: (111, 'Connection refused')
2) lightblue._obexcommon.OBEXError: (11, 'Resource temporarily unavailable')

how i can do it?

example:

try:
     lightblue.obex.sendfile(device.getAddr(), c[1],"advertisement.jpg")
except lightblue._obexcommon.OBEXError????????????:
      print "Connection refused!"
except lightblue._obexcommon.OBEXError????????????:
      print "Resource temporarily unavailable!"

Try something like this:

try:
    lightblue.obex.sendfile(device.getAddr(), c[1],"advertisement.jpg")
except lightblue._obexcommon.OBEXError, error:
    if error.args[0] == 111:
        print "Connection refused!"
    elif error.args[0] == 11:
        print "Resource temporarily unavailable!"
    else:
        pass

Try something like this:

try:
    lightblue.obex.sendfile(device.getAddr(), c[1],"advertisement.jpg")
except lightblue._obexcommon.OBEXError, error:
    if error.args[0] == 111:
        print "Connection refused!"
    elif error.args[0] == 11:
        print "Resource temporarily unavailable!"
    else:
        pass

Ok thanks.

:icon_mrgreen:

Or if you want to be especially clean:

try:
    lightblue.obex.sendfile(device.getAddr(), c[1],"advertisement.jpg")
except lightblue._obexcommon.OBEXError, error:
    if error.args[0] == 111:
        print "Connection refused!"
    elif error.args[0] == 11:
        print "Resource temporarily unavailable!"
    else:
        raise error
This question has already been answered. Start a new discussion instead.