Skip to content

Fix NameError when visit_error is set in visit_uri (#851)#852

Open
mohityadav8 wants to merge 2 commits intoaboutcode-org:mainfrom
mohityadav8:fix-visit-error-851
Open

Fix NameError when visit_error is set in visit_uri (#851)#852
mohityadav8 wants to merge 2 commits intoaboutcode-org:mainfrom
mohityadav8:fix-visit-error-851

Conversation

@mohityadav8
Copy link
Copy Markdown

Description

This PR fixes a potential NameError in visit_uri() located in minecode/management/commands/run_visit.py.

Previously, the code referenced the exception variable e inside the if visit_error: block:

msg += get_error_message(e)

However, e is only defined inside the except block:

except (ConnectionError, Timeout, Exception) as e:

If _visit_router.process(uri_to_visit) returns a visit_error without raising an exception, the if visit_error: block executes while e is undefined, causing:

NameError: name 'e' is not defined

This PR resolves the issue by removing the reference to e and using visit_error directly when logging the error message.

This ensures the error logging works correctly even when no exception was raised.

Fixes #851.

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.

NameError: 'e' referenced outside except block in visit_uri() when visit_error is set

1 participant