Browse Source

Proper exception chaining.

pull/95/head
Rapptz 9 years ago
parent
commit
4edff12f6b
  1. 4
      discord/ext/commands/bot.py
  2. 8
      discord/ext/commands/core.py
  3. 2
      discord/voice_client.py

4
discord/ext/commands/bot.py

@ -456,8 +456,8 @@ class Bot(GroupMixin, discord.Client):
lib = importlib.import_module(name)
try:
lib.setup(self)
except AttributeError:
raise discord.ClientException('extension does not have a setup function')
except AttributeError as e:
raise discord.ClientException('extension does not have a setup function') from e
self.extensions[name] = lib

8
discord/ext/commands/core.py

@ -183,8 +183,8 @@ class Command:
elif converter is discord.Invite:
try:
return bot.get_invite(argument.strip())
except:
raise BadArgument('Invite is invalid')
except Exception as e:
raise BadArgument('Invite is invalid') from e
def _get_converter(self, param):
converter = param.annotation
@ -217,8 +217,8 @@ class Command:
return self.do_conversion(ctx.bot, ctx.message, converter, argument)
except CommandError as e:
raise e
except Exception:
raise BadArgument('Converting to "{0.__name__}" failed.'.format(converter))
except Exception as e:
raise BadArgument('Converting to "{0.__name__}" failed.'.format(converter)) from e
@property
def clean_params(self):

2
discord/voice_client.py

@ -400,7 +400,7 @@ class VoiceClient:
p = subprocess.Popen(args, stdin=stdin, stdout=subprocess.PIPE)
return ProcessPlayer(p, self, after)
except subprocess.SubprocessError as e:
raise ClientException('Popen failed: {0.__name__} {1}'.format(type(e), str(e)))
raise ClientException('Popen failed: {0.__name__} {1}'.format(type(e), str(e))) from e
def create_ytdl_player(self, url, *, options=None, use_avconv=False, after=None):

Loading…
Cancel
Save