diff options
author | Maxime “pep” Buquet <pep@bouah.net> | 2022-04-04 21:53:34 +0200 |
---|---|---|
committer | Maxime “pep” Buquet <pep@bouah.net> | 2022-04-06 10:41:04 +0200 |
commit | 1338fcf9b9dc89890127b5d20e43726c56d9b579 (patch) | |
tree | df6ea5171451146cc04b7311f9e3369a01dc9ca7 /poezio/core/core.py | |
parent | 12af2c5e47893c190926c13d83c6bfc6972390f6 (diff) | |
download | poezio-1338fcf9b9dc89890127b5d20e43726c56d9b579.tar.gz poezio-1338fcf9b9dc89890127b5d20e43726c56d9b579.tar.bz2 poezio-1338fcf9b9dc89890127b5d20e43726c56d9b579.tar.xz poezio-1338fcf9b9dc89890127b5d20e43726c56d9b579.zip |
core: Log InvalidCABundle error in info buffer
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
Diffstat (limited to 'poezio/core/core.py')
-rw-r--r-- | poezio/core/core.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/poezio/core/core.py b/poezio/core/core.py index 0c71b566..7690e769 100644 --- a/poezio/core/core.py +++ b/poezio/core/core.py @@ -29,9 +29,11 @@ from typing import ( TYPE_CHECKING, ) from xml.etree import ElementTree as ET +from pathlib import Path from slixmpp import Iq, JID, InvalidJID from slixmpp.util import FileSystemPerJidCache +from slixmpp.xmlstream.xmlstream import InvalidCABundle from slixmpp.xmlstream.handler import Callback from slixmpp.exceptions import IqError, IqTimeout, XMPPError @@ -674,6 +676,26 @@ class Core: self.do_command(''.join(char_list), True) self.doupdate() + def loop_exception_handler(self, loop, context) -> None: + """Do not log unhandled iq errors and timeouts""" + handled_exceptions = (IqError, IqTimeout, InvalidCABundle) + if not isinstance(context['exception'], handled_exceptions): + loop.default_exception_handler(context) + elif isinstance(context['exception'], InvalidCABundle): + paths = context['exception'].path + error = ( + 'Poezio could not find a valid CA bundle file automatically. ' + 'Ensure the ca_cert_path configuration is set to a valid ' + 'CA bundle path, generally provided by the \'ca-certificates\' ' + 'package in your distribution.' + ) + if isinstance(paths, (str, Path)): + # error += '\nFound the following value: {path}'.format(path=str(path)) + paths = [paths] + if paths is not None: + error += f"\nThe following values were tried: {str([str(s) for s in paths])}" + self.information(error, 'Error') + def save_config(self): """ Save config in the file just before exit |