This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Simple, transparent, name-spaced exceptions across JSON-RPC services.


The rpc_exceptions project lives on github, and is available via pip.

Installing v0.1 From Pip

sudo pip install rpc_exceptions==0.1

Installing v0.1 From Source

curl | tar vzxf -
cd rpc_exceptions
sudo python install


Define a base exception with an api_name, exceptions for that API, and instantiate RPCExceptionHandler with those exceptions:

from rpc_exceptions import RPCExceptionHandler, WrappedRPCError

class TestError(WrappedRPCError):
    api_name = 'test'

class PEBCAKError(TestError):
    code = -1
    _default_message = 'Problem exists between chair and keyboard'

class FUBARError(TestError):
    code = -2
    _default_message = 'FUBARed'

error_handler = RPCExceptionHandler([ PEBCAKError, FUBARError ])

Decorate exposed functions with the instantiated RPCExceptionHandler’s wrap_rpc_exception decorator:

from wrapped_rpc.exceptions import error_handler, PEBCAKError, FUBARError
def fail1(arg):
    raise PEBCAKError

def fail2(arg):
    raise FUBARError

Coerce error codes and messages to exceptions the instantiated RPCExceptionHandler’s get_exception_instance method:

#client using tinyrpc
from wrapped_rpc.exceptions import error_handler, PEBCAKError, FUBARError
from tinyrpc import RPCClient, RPCError
from tinyrpc.protocols.jsonrpc import JSONRPCProtocol
from tinyrpc.transports.http import HttpPostClientTransport

class WrappedRPCClient(RPCClient):
    def __init__(self, protocol, transport, api_name):
        self.protocol = protocol
        self.transport = transport
        self.api_name = api_name

    def _send_and_handle_reply(self, req):
        reply = self.transport.send_message(req.serialize())
        response = self.protocol.parse_reply(reply)
        if hasattr(response, 'error'):
                raise error_handler.get_exception_instance(
                         self.api_name, response.error)
            except KeyError:
                raise RPCError('Error calling remote procedure: %s' %\
        return response

rpc_client = WrappedRPCClient(
server = rpc_client.get_proxy()

except PEBCAKError as e:
    print 'code: %s, message: %s' % (e.code, e.msg)

except FUBARError as e:
    print 'code: %s, message: %s' % (e.code, e.msg)



Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
rpc_exceptions-0.1.tar.gz (3.8 kB) Copy SHA256 Checksum SHA256 Source Apr 29, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting