Remove empty except (#887)

This commit is contained in:
josephbiko 2018-07-09 20:54:43 +02:00 committed by Lonami
parent 4328663c78
commit e6981e7676
4 changed files with 17 additions and 8 deletions

View File

@ -32,6 +32,6 @@ times, in this case, ``22222`` so we can hardcode that:
client = TelegramClient(None, api_id, api_hash)
client.session.set_dc(2, '149.154.167.40', 80)
loop.run_until_complete(client.start(
client.start(
phone='9996621234', code_callback=lambda: '22222'
))
)

View File

@ -210,7 +210,10 @@ class UpdateMethods(UserMethods):
continue # We actually just want to act upon timeout
except asyncio.TimeoutError:
pass
except:
except asyncio.CancelledError:
await self.disconnect()
return
except Exception as e:
continue # Any disconnected exception should be ignored
# We also don't really care about their result.
@ -273,7 +276,7 @@ class UpdateMethods(UserMethods):
type(event).__name__)
)
break
except:
except Exception:
__log__.exception('Unhandled exception on {}'
.format(callback.__name__))

View File

@ -36,7 +36,7 @@ def report_error(code, message, report_method):
)
url.read()
url.close()
except:
except Exception as e:
"We really don't want to crash when just reporting an error"

View File

@ -386,6 +386,7 @@ class MTProtoSender:
except asyncio.TimeoutError:
continue
except asyncio.CancelledError:
await self.disconnect()
return
except Exception as e:
if isinstance(e, ConnectionError):
@ -425,6 +426,7 @@ class MTProtoSender:
except asyncio.TimeoutError:
continue
except asyncio.CancelledError:
await self.disconnect()
return
except Exception as e:
if isinstance(e, ConnectionError):
@ -467,15 +469,19 @@ class MTProtoSender:
__log__.info('Server replied with an unknown type {:08x}: {!r}'
.format(e.invalid_constructor_id, e.remaining))
continue
except:
__log__.exception('Unhandled exception while unpacking')
except asyncio.CancelledError:
await self.disconnect()
return
except Exception as e:
__log__.exception('Unhandled exception while unpacking %s',e)
await asyncio.sleep(1)
else:
try:
await self._process_message(message)
except asyncio.CancelledError:
await self.disconnect()
return
except:
except Exception as e:
__log__.exception('Unhandled exception while '
'processing %s', message)
await asyncio.sleep(1)