Skip to content

Commit

Permalink
Added 'On exceptions' section to the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
taras committed Oct 15, 2024
1 parent 56833c2 commit 29d042c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ picows Release History
------------------

* Added optional automatic replies to incoming PING messages, enabled by default
* Added auto_ping_strategy argument to ws_connect/ws_create_server that controls when pings are sent

1.5.0 (2024-10-10)
------------------
Expand Down
24 changes: 24 additions & 0 deletions docs/source/guides.rst
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,27 @@ debug logging.
# Or set picows logger log level only
logging.basicConfig(level=logging.INFO)
logging.getLogger("picows").setLevel(picows.PICOWS_DEBUG_LL)
On exceptions
-------------

When talking about how library deals with exceptions, there are 2 questions that
must be addressed:

**What kind of exceptions the library functions can throws?**

**picows** may throw any exception that the underlying system calls may throw.
Think about `ConnectionResetError` from :any:`ws_connect` or `BrokenPipeError`
from :any:`WSTransport.send`.
**picows** doesn't wrap these exceptions into it's own special exception type.
Additionally :any:`ws_connect` may throw :any:`WSError` in case when there are
websocket negotiation errors.
In general :any:`WSError` is reserved for anything that is only specific to
websockets.

**What happens if a user callback throw an exception, how does the library handles it?**

It is described in the docs of a particular method. Most of the times **picows** will
send a CLOSE frame with INTERNAL_ERROR close code and disconnect. But for
:any:`on_ws_frame` it is possible to override it by specifying disconnect_on_error=False
to :any:`ws_connect`/:any:`ws_create_server`
2 changes: 1 addition & 1 deletion picows/picows.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ cdef extern from "picows_compat.h" nogil:

class WSError(RuntimeError):
"""
Currently it is only thrown by :any:`ws_connect` on handshake errors.
Thrown by :any:`ws_connect` on any kind of handshake errors.
"""
pass

Expand Down

0 comments on commit 29d042c

Please sign in to comment.