jahschwa / sibyl

a python chatbot with a focus on XBMC
GNU General Public License v3.0
7 stars 6 forks source link

matrix: Excptions not handled correctly #48

Closed jahschwa closed 5 years ago

jahschwa commented 6 years ago

This appears to stem from using the wrong Exception class in try/except blocks. I don't know if it makes sense in every case to use the absolute parent MatrixError from:

https://github.com/matrix-org/matrix-python-sdk/blob/master/matrix_client/errors.py#L17

But currently the following is possible when joining a room (and almost definitely in other places as well):

2018-05-31 00:22:10 | sibylbot | CRI | UNHANDLED: MatrixHttpLibError

Traceback (most recent call last):
  File "/home/sibyl/sibyl/lib/sibylbot.py", line 1205, in run_forever
    self.__run_forever()
  File "/home/sibyl/sibyl/lib/sibylbot.py", line 1074, in __run_forever
    self.__serve()
  File "/home/sibyl/sibyl/lib/sibylbot.py", line 1057, in __serve
    proto.join_room(proto.new_room(room['room'],room['nick'],pword))
  File "protocols/sibyl_matrix.py", line 354, in join_room
    res = self.client.join_room(room.room.room_id)
  File "/home/sibyl/sibyl/src/matrix-client/matrix_client/client.py", line 289, in join_room
    response = self.api.join_room(room_id_or_alias)
  File "/home/sibyl/sibyl/src/matrix-client/matrix_client/api.py", line 185, in join_room
    return self._send("POST", path)
  File "/home/sibyl/sibyl/src/matrix-client/matrix_client/api.py", line 659, in _send
    raise MatrixHttpLibError(e, method, endpoint)
MatrixHttpLibError: Something went wrong in POST requesting https://terracrypt.net/_matrix/client/r0/join/%21DgdmLpMqcBYqfuUFka%3Aterracrypt.net: HTTPSConnectionPool(host='terracrypt.net', port=443): Max retries exceeded with url: /_matrix/client/r0/join/%21DgdmLpMqcBYqfuUFka%3Aterracrypt.net?access_token=<REDACTED> (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7ff914004210>: Failed to establish a new connection: [Errno 110] Connection timed out',))

2018-05-31 00:22:10 | sibylbot | CRI | Please consider reporting the above error to the developers.