Skip to content

Error handling improvements#125

Merged
szeiger merged 5 commits intodatabricks:masterfrom
szeiger:error-handling
Aug 9, 2021
Merged

Error handling improvements#125
szeiger merged 5 commits intodatabricks:masterfrom
szeiger:error-handling

Conversation

@szeiger
Copy link
Copy Markdown
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

szeiger added 5 commits July 8, 2021 14:56
- 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
Copy Markdown
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

2 participants