django-modern-rpc icon indicating copy to clipboard operation
django-modern-rpc copied to clipboard

Nice would be logging RPCInternalError as error (with traceback) but it is currently logged as warning

Open tgz-cz opened this issue 1 year ago • 2 comments
trafficstars

I prefer to log unexpected exception (that is converted to RPCInternalError) as error with traceback. (Or add some settings value so that it can be configured to be logged as error)

Otherwise I must wrap all my RPC-functions by my own wrapper to be error logged:

 @rpc_method
 def divide(a, b):
     try:
         return a / b
     except RPCException:
        raise
     except Exception as exc:
         logging.exception(f"RPCInternalError: {exc}")
         raise RPCInternalError(str(exc)) from exc

Because "default exception handler" does not log errors, but warnings in this case https://github.com/alorence/django-modern-rpc/blob/main/modernrpc/core.py#L149C9-L151C54

tgz-cz avatar Sep 10 '24 13:09 tgz-cz