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

Compiler SyntaxError #5

Closed
ahopkins opened this issue Mar 4, 2021 · 0 comments
Closed

Compiler SyntaxError #5

ahopkins opened this issue Mar 4, 2021 · 0 comments

Comments

@ahopkins
Copy link
Member

ahopkins commented Mar 4, 2021

It would be helpful to add a catch for SyntaxError in the compiler to output the source. Something like this, except abstracted so that line numbers and source can be displayed in other uses as well:

            try:
                compiled_src = compile(
                    self.find_route_src,
                    "",
                    "exec",
                )
            except SyntaxError as e:
                lines = self.find_route_src.split("\n")
                pad = len(str(len(lines)))
                logger.error(
                    "\n".join(
                        f"{str(idx+1).rjust(pad)}: {line}"
                        for idx, line in enumerate(lines)
                    )
                )
                raise e
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

No branches or pull requests

1 participant