Skip to content

Trying to run a command with a non-existing infraction ID result in a traceback #1375

@sentry

Description

@sentry

If a conversion is tried on a non-existing infraction, it should be gracefully handled instead of throwing a 404 exception.

Sentry Issue: BOT-M2

ResponseCodeError: Status: 404 Response: {'detail': 'Not found.'}
  File "bot/api.py", line 67, in maybe_raise_for_status
    raise ResponseCodeError(response=response, response_json=response_json)
  File "bot/api.py", line 75, in request
    await self.maybe_raise_for_status(resp, raise_for_status)
  File "bot/api.py", line 80, in get
    return await self.request("GET", endpoint, raise_for_status=raise_for_status, **kwargs)
  File "bot/converters.py", line 578, in convert
    return await ctx.bot.api_client.get(f"bot/infractions/{arg}")
  File "discord/ext/commands/core.py", line 451, in _actual_conversion
    ret = await instance.convert(ctx, argument)

ConversionError: (<class 'bot.converters.Infraction'>, ResponseCodeError())
  File "discord/ext/commands/core.py", line 464, in _actual_conversion
    raise ConversionError(converter, exc) from exc
  File "discord/ext/commands/core.py", line 505, in do_conversion
    return await self._actual_conversion(ctx, converter, argument, param)
  File "discord/ext/commands/core.py", line 552, in transform
    return await self.do_conversion(ctx, converter, argument, param)
  File "discord/ext/commands/core.py", line 697, in _parse_arguments
    transformed = await self.transform(ctx, param)
  File "discord/ext/commands/core.py", line 790, in prepare
    await self._parse_arguments(ctx)
...
(3 additional frame(s) were not displayed)

Error executing command invoked by [REDACTED]: !i e 26984Bye bye | [REDACTED] 

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: moderationRelated to community moderation functionality: (moderation, defcon, verification)l: 0 - beginnerp: 3 - lowLow Priorityt: bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions