Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECR::Lexer#consume_control should raise Crystal::SyntaxException instead of Exception #15220

Open
nobodywasishere opened this issue Nov 24, 2024 · 1 comment · May be fixed by #15222
Open

ECR::Lexer#consume_control should raise Crystal::SyntaxException instead of Exception #15220

nobodywasishere opened this issue Nov 24, 2024 · 1 comment · May be fixed by #15222

Comments

@nobodywasishere
Copy link
Contributor

This is related to adding support for ECR files to ameba (here). Currently, there's no easy way to get line/column information about where an ECR syntax error is when calling ECR.process_string. One suggestion to fix this is to replace the generic raises with raising Crystal::SyntaxException, which is what the compiler currently uses to capture line/column/file information. Alternatively, there could be a rescue block added to process_string that re-raises with the line/column/file information, either would work.

@nobodywasishere nobodywasishere changed the title ECR::Lexer#consume_control should raise Crystal::SyntaxException instead of just Exception ECR::Lexer#consume_control should raise Crystal::SyntaxException instead of just Exception Nov 24, 2024
@nobodywasishere nobodywasishere changed the title ECR::Lexer#consume_control should raise Crystal::SyntaxException instead of just Exception ECR::Lexer#consume_control should raise Crystal::SyntaxException instead of Exception Nov 24, 2024
@nobodywasishere
Copy link
Contributor Author

nobodywasishere commented Nov 24, 2024

Alternatively (what I'm leaning towards) is just having a custom exception that includes the line/column information. See https://github.com/nobodywasishere/crystal/tree/nobody/ecr-syntax-exception

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants