Skip to content

Commit

Permalink
documentation for methodcall error handler
Browse files Browse the repository at this point in the history
  • Loading branch information
irmen committed Aug 16, 2020
1 parent f1b0441 commit 82e67cc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Change Log
- reworked the timezones example. (it didn't work as intended)
- httpgateway message data bytearray type fix
- fixed ipv6 error in filetransfer example

- added methodcall_error_handler in documentation


**Pyro 5.10**
Expand Down
16 changes: 16 additions & 0 deletions docs/source/servercode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -799,3 +799,19 @@ object name. You can use it directly but it is preferable to use the constant
>>> daemon.registered()
['Pyro.NameServer', 'Pyro.Daemon']


Intercepting errors in user code executed in a method call
----------------------------------------------------------
When a method call is executed in a Pyro server/daemon, it eventually will execute some
user written code that implements the remote method. This user code may raise an exception
(intentionally or not). Normally, Pyro will only report the exception to the calling client.

It may be useful however to also process the error on the *server*, for instance, to log the error
somewhere for later reference. For this purpose, you can set the ``methodcall_error_handler`` attribute
on the daemon object to a custom error handler function. See the :file:`exceptions` example.
This function's signature is::

def custom_error_handler(daemon: Daemon, client_sock: socketutil.SocketConnection,
method: Callable, vargs: Sequence[Any], kwargs: Dict[str, Any],
exception: Exception) -> None

0 comments on commit 82e67cc

Please sign in to comment.