====== tinyrpc ====== ===== exception ===== [[https://www.jsonrpc.org/specification#error_object|JSON-RPC 2.0 5.1 Error object]] [[https://tinyrpc.readthedocs.io/en/latest/jsonrpc.html#adding-custom-exceptions|Adding custom exceptions]] By default dispatcher catches all exceptions in registered methods: [[https://github.com/mbr/tinyrpc/blob/1.1.4/tinyrpc/dispatch/__init__.py#L266]] except Exception as e: # an error occurred within the method, return it return request.error_respond(e) and exception ''e'' is wrapped as response using ''RPCRequest.error_respond()'': * [[https://github.com/mbr/tinyrpc/blob/1.1.4/tinyrpc/protocols/__init__.py#L62|RPCRequest.error_respond()]] * [[https://github.com/mbr/tinyrpc/blob/1.1.4/tinyrpc/protocols/jsonrpc.py#L377|JSONRPCRequest.error_respond()]] * [[https://github.com/mbr/tinyrpc/blob/1.1.4/tinyrpc/protocols/jsonrpc.py#L287|_get_code_message_and_data()]] TODO: How to provide more detailed exception do client - i.e. exception type and backtrace ? Possible solutions: - Create own ''RPCDispatcher'' with own ''dispatch()'' method, where exception will carry also ''.data'' - Create own JSONRPCProtocol with changed JSONRPCRequest().error_respond(), where full exception is unwinded and serialized in JSON data field.