How to make @anvil.server.callable work with a second decorator?

I have the following callable server function:

@anvil.server.callable
def fetch_account():
  ...

I am trying to add a second decorator to it below the @anvil.server.callable decorator:

@anvil.server.callable
@exception_handler
def fetch_account():
  ...

However, this makes my function unidentifiable on the client-side. I.e., when I try to call it from the client with anvil.server.call('fetch_account'), I get the following error:
image

Here is the code for my exception_handler decorator:

def exception_handler(func):
    def wrapper(*args, **kw):
        try:
            return func(*args, **kw)
        except Exception as e:
            exception_traceback = traceback.format_exc()
            log_uncaught_exception(e, environment='server', traceback=exception_traceback)
            raise Exception(traceback.format_exc()) 
    return wrapper

Is there any way to make the extra decorators not break @anvil.server.callable?

You probably need to use functools. There’s an example at anvil-extras/server_code/authorisation.py at main · anvilistas/anvil-extras · GitHub

1 Like

Lovely! Thank you Owen