← Back to team overview

maas-devel team mailing list archive

Don't forget to catch declared exceptions in RPC handlers

 

Hi all

I've noticed that there's a fair bit of code out there that is doing stuff 
like this:

@asynchronous
@inlineCallbacks
def foo():
    yield(SomeRPCFunction, arg)
    DoSomethingElse()

Where SomeRPCFunction has declared in its definition an "errors" structure 
which lists all the possible exceptions.

Please don't forget to catch these exceptions on the caller side!  e.g.

@asynchronous
@inlineCallbacks
def foo():
    try:
        yield(SomeRPCFunction, arg)
    except FooException:
        log("aieeee")
    else:
        DoSomethingElse()



Follow ups