Skip to content

Added modern exception -based error system for Stroll#10

Merged
LiamWJH merged 1 commit into
stroll-script:mainfrom
Deekshith-M13:improve-error-system
Nov 16, 2025
Merged

Added modern exception -based error system for Stroll#10
LiamWJH merged 1 commit into
stroll-script:mainfrom
Deekshith-M13:improve-error-system

Conversation

@Deekshith-M13

Copy link
Copy Markdown

PR Description

This PR improves the error-handling system in Stroll by introducing real Python exception classes while keeping the old error objects intact for backward compatibility.

What I changed

Added a new StrollError base class that inherits from Python’s Exception.
Added specific exception subclasses like SyntaxErrorStroll, RuntimeErrorStroll, TypeErrorStroll, etc.
Added optional support for line, column, filename, and token information inside errors.
Added a raise_syntax() helper function to simplify throwing syntax errors from the parser.
Kept the old classes (Syntaxerror, Miscerror, Extensionerror) and terminate() to avoid breaking existing interpreter code.

Why I made these changes

The previous error classes were not real exceptions, so they couldn’t be raised or caught properly.
You used os._exit(1) which immediately kills execution, making the REPL and debugging difficult.
Adding structured exceptions lays the groundwork for better error messages, safer parsing, and a more reliable runtime.
Keeping the legacy system allows the project to transition gradually without breaking anything.

Benefits

You can handle errors more cleanly in the future (especially in the REPL).
Parser and runtime will be able to throw detailed errors with line/column info.
This makes future improvements (like better syntax errors, stack traces, and testing) much easier.
No breaking changes — existing code still works exactly the same.

@Deekshith-M13

Copy link
Copy Markdown
Author

I hope You will merge this to your main branch, If there is no conflict please merge it I need it for my college!

@LiamWJH

LiamWJH commented Nov 16, 2025

Copy link
Copy Markdown
Collaborator

Thank you 🙏 I appreciate your effort! I hope you get good scores and grades!

@LiamWJH
LiamWJH merged commit c41c05c into stroll-script:main Nov 16, 2025
@Deekshith-M13

Copy link
Copy Markdown
Author

Thanks mate!!! If i have more time I will contribute more to your project!

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