insights-core icon indicating copy to clipboard operation
insights-core copied to clipboard

Simplify re-raise for non-legacy

Open Glutexo opened this issue 4 months ago • 1 comments

All Pull Requests:

Check all that apply:

  • [x] Have you followed the guidelines in our Contributing document, including the instructions about commit messages?
  • [x] No Sensitive Data in this change?
  • [x] Is this PR to correct an issue?
  • [ ] Is this PR an enhancement?

Complete Description of Additions/Changes:

To avoid confusion for developers, removed the unnecessary conditional for exception re-raise.

  • It is unnecessary to set last_ex on non-legacy, because there is no fallback to other URLs. Only one URL is tried and if it fails, there is only a single exception.
  • The if last_ex condition can never be false, because if an exception is not raised, the function hits a return clause earlier. It only gets to the conditional if an exception has been caught.

A simple raise is enough. Without an argument, the last caught exception is re-raised by default. It’s thus equivalent to raise exc.

Card IDs:

Glutexo avatar Oct 17 '24 08:10 Glutexo