Skip to content

Exception refactor#870

Open
adjordjevic-TT wants to merge 12 commits intomainfrom
adjordjevic/exception_refactor
Open

Exception refactor#870
adjordjevic-TT wants to merge 12 commits intomainfrom
adjordjevic/exception_refactor

Conversation

@adjordjevic-TT
Copy link
Collaborator

@adjordjevic-TT adjordjevic-TT commented Jan 22, 2026

Exception refactor that essentially centralized exceptions by creating exceptions.py to store all of our custom exceptions. Already existing exceptions were moved there and bunch of new ones were created to make it easier to see what went wrong. Additional benefit is when testing we can target specific exceptions that we expect to get rather than passing test if any exception is raised (this already found bug in test_mailboxes_communication_lockup.py which essentially always passed because when failing we would raise an exception that we would catch and say that everything went fine).
Also, we will have easier time identifying which exception was raised by checking exception type rather than parsing exception output.

@adjordjevic-TT adjordjevic-TT marked this pull request as ready for review January 23, 2026 15:57
Comment on lines 17 to 18
class TTTimeoutError(TTException):
"""Raised when an expected operation times out."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... We should minimize changes to reduce LLM bloatware...
For example, this exception is base for single exception. Why do we have it? What does it bring?
Ideally, exception would carry more info than just an error message, so user can inspect it if it needs to be processed or re-raised.
Can you go through exceptions and see which ones don't make sense? Which one should have more info assigned to it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, is it fine for all of those which we decide are too specific to default to TTException?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It is totally fine to have one generic exception type. But others need to be more specific...
Also, it is totally fine to split this PR into more, meaning you don't have to solve everything in this PR.

Copy link
Member

@tt-vjovanovic tt-vjovanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though it was vibe coded, at the end, you are responsible for this code change. If you vibe code, first review it yourself, when you are satisfied with it, send other to take a look at your changes. Then there is no need to have warning at top mentioning that it was heavily vibe coded.

f"Section {section.name} loaded successfully to address 0x{address:08x}. Size: {len(section.data)} bytes"
)
except Exception as e:
except (TTException, ValueError, OSError) as e:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another example, do we want to allow other exception to pass through to the user?
Do we want to make exception type for ElfLoader? Where do we put boundary on what gets new exception type and what continues to use existing TTException?

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