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

Error handling improvements #125

Merged
merged 5 commits into from
Aug 9, 2021
Merged

Conversation

szeiger
Copy link
Collaborator

@szeiger szeiger commented Jul 12, 2021

  • More consistent error handling:
    • Remove Error.Delegate
    • Skip JVM stack trace handling
    • Consistent formatting of raw delegate errors and regular positioned errors
  • Unify error stack trace handling:
    Instead of sprinkling error propagation with or without stack frames all over the Evaluator and other parts of the codebase, we now do it in one place (visitExpr) with additional logic in Error.withStackFrame. Duplicate frames are skipped, an error without any stack frame always gets the current position, and all other frames are added or skipped depending on the Expr at the position.
  • Add expression types to stack traces:
    This makes stack traces much more descriptive. We also change some of the reported positions / expr types to better match the semantics of the errors.
  • Consistent treatment of parse errors:
    They are reported as sjsonnet.ParseError with normal stack traces instead of the previous one-liners which required customized error messages for parse errors in imported files. Errors are now stored as Error objects instead of Strings in the parse cache. This paves the way for error reporting during static evaluation and it is already required now to translate the paths in parse error stack traces to a different base directory (when reusing a cached parse error from a previous run).
  • Static errors for unknown variables:
    Unknown variables and illegal self/super/$ references are now checked statically as they are supposed to be. Error messages are consistent with Google Jsonnet's.

Fixes #122

- Remove Error.Delegate
- Skip JVM stack trace handling
- Consistent formatting of raw delegate errors and regular positioned errors
Instead of sprinkling error propagation with or without stack frames all over the Evaluator and other parts of the codebase, we now do it in one place (visitExpr) with additional logic in Error.withStackFrame. Duplicate frames are skipped, an error without any stack frame always gets the current position, and all other frames are added or skipped depending on the Expr at the position.
This makes stack traces much more descriptive. We also change some of the reported positions / expr types to better match the semantics of the errors.
They are reported as sjsonnet.ParseError with normal stack traces instead of the previous one-liners which required customized error messages for parse errors in imported files. Errors are now stored as Error objects instead of Strings in the parse cache. This paves the way for error reporting during static evaluation and it is already required now to translate the paths in parse error stack traces to a different base directory (when reusing a cached parse error from a previous run).
Unknown variables and illegal self/super/$ references are now checked statically as they are supposed to be. Error messages are consistent with Google Jsonnet's.
Fixes databricks#122
@iuliand-db iuliand-db self-requested a review August 3, 2021 10:03

def asSeenFrom(ev: EvalErrorScope): Error =
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

@szeiger szeiger merged commit 6aa300a into databricks:master Aug 9, 2021
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.

Unknown variables should be rejected statically
2 participants