Skip to content

Replace bare except clauses with specific exception handling#119

Draft
Copilot wants to merge 3 commits into
refactor_modelsfrom
copilot/sub-pr-116-another-one
Draft

Replace bare except clauses with specific exception handling#119
Copilot wants to merge 3 commits into
refactor_modelsfrom
copilot/sub-pr-116-another-one

Conversation

Copilot AI commented Dec 7, 2025

Copy link
Copy Markdown

Addresses code review feedback on PR #116 regarding bare except: clauses that silently catch all exceptions without documentation.

Changes

  • Line 1123: Replace except: with except TradeRequest.DoesNotExist: when attempting to retrieve timetable_slug from a trade request
  • Line 1159: Replace except: with except TradeMatch.DoesNotExist: when attempting to retrieve timetable_slug from a trade match
  • Add explanatory comments documenting the intended fallback behavior when these lookups fail

Before:

try:
    trade_request = TradeRequest.objects.get(pk=request_id)
    timetable_slug = trade_request.offered_allocation.timetable.slug
except:
    pass

After:

try:
    trade_request = TradeRequest.objects.get(pk=request_id)
    timetable_slug = trade_request.offered_allocation.timetable.slug
except TradeRequest.DoesNotExist:
    # If trade request doesn't exist, timetable_slug remains None and default view is shown
    pass

This prevents accidentally catching system exits, keyboard interrupts, and unrelated exceptions while making the code's intent explicit.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits December 7, 2025 17:07
…ents

Co-authored-by: Foosec <31885466+Foosec@users.noreply.github.com>
Co-authored-by: Foosec <31885466+Foosec@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on models refactor and resource groups implementation Replace bare except clauses with specific exception handling Dec 7, 2025
Copilot AI requested a review from Foosec December 7, 2025 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants