narrow except Exception in clothoid path planner and state machine display to specific types#1387
Open
HrachShah wants to merge 2 commits into
Open
narrow except Exception in clothoid path planner and state machine display to specific types#1387HrachShah wants to merge 2 commits into
HrachShah wants to merge 2 commits into
Conversation
added 2 commits
May 25, 2026 03:40
…rom Exception to specific types — clothoid computations raise ValueError or TypeError; PlantUML image display raises OSError, ValueError, or TypeError; catching all Exception masked unrelated bugs
…o (ValueError, TypeError) — numeric computations in solve_g_for_root and compute_* helpers only raise these types; catching all Exception masked unrelated bugs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two bare
except Exceptionblocks inPathPlanning/ClothoidPath/clothoid_path_planner.py(generate_clothoid_pathouter try) andMissionPlanning/StateMachine/state_machine.py(PlantUML image display) were narrowed to specific exception tuples.generate_clothoid_pathouter try →except (ValueError, TypeError).state_machine.pyPlantUML display →except (OSError, ValueError, TypeError).Why
generate_clothoid_pathdoes numeric computations insolve_g_for_rootand thecompute_*helpers — these only raiseValueError(e.g.math.sin/math.cosof inf, numpy linalg convergence failures that propagateValueError) andTypeError(when a parameter is the wrong shape, which should not be caught here either, but the original intent of the bare-except was clearly "skip and continue" for malformed geometry). Catching allExceptionswallowed real bugs likeNameErrorfrom a typo andAttributeErrorfrom a refactor.state_machine.pyPlantUML display opens aBytesIObuffer and callsplt.imshow(imread(BytesIO(content), format="png")). The realistic failure modes areOSError(matplotlib I/O failure, missing image format backend),ValueError(malformed image bytes), andTypeError(non-bytes content).KeyboardInterruptandSystemExitshould propagate during a long render.Catching all
Exceptionwas the wrong shape for both blocks; narrowing preserves the original "skip and print a friendly message" intent while letting unrelated bugs surface.