Projects STRLCPY maigret Commits d5bc92d2
🤬
  • Fixed catching of python-specific exception

  • Loading...
  • Soxoj committed 4 years ago
    d5bc92d2
    1 parent f7263c9b
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    maigret/checking.py
    skipped 1 lines
    2 2  import logging
    3 3  import re
    4 4  import ssl
     5 +import sys
    5 6   
    6 7  import aiohttp
    7 8  import tqdm.asyncio
    skipped 53 lines
    61 62   except asyncio.TimeoutError as errt:
    62 63   error_text = "Timeout Error"
    63 64   expection_text = str(errt)
    64  - except (ssl.SSLCertVerificationError, ssl.SSLError) as err:
    65  - error_text = "SSL Error"
    66  - expection_text = str(err)
    67 65   except aiohttp.client_exceptions.ClientConnectorError as err:
    68 66   error_text = "Error Connecting"
    69 67   expection_text = str(err)
    skipped 4 lines
    74 72   error_text = "Proxy Error"
    75 73   expection_text = str(err)
    76 74   except Exception as err:
    77  - logger.warning(f'Unhandled error while requesting {site_name}: {err}')
    78  - logger.debug(err, exc_info=True)
    79  - error_text = "Some Error"
    80  - expection_text = str(err)
     75 + # python-specific exceptions
     76 + if sys.version_info.minor > 6:
     77 + if isinstance(err, ssl.SSLCertVerificationError) or isinstance(err, ssl.SSLError):
     78 + error_text = "SSL Error"
     79 + expection_text = str(err)
     80 + else:
     81 + logger.warning(f'Unhandled error while requesting {site_name}: {err}')
     82 + logger.debug(err, exc_info=True)
     83 + error_text = "Some Error"
     84 + expection_text = str(err)
    81 85   
    82 86   # TODO: return only needed information
    83 87   return html_text, status_code, error_text, expection_text
    skipped 522 lines
Please wait...
Page is in error, reload to recover