Skip to content

Consider try / catch functionality #415

Open
@sparkprime

Description

@sparkprime

Currently error "foo" is like throwing an exception, but there is no way to catch the exception.

Motivations for "catch":

  1. Routines that loop over data and trigger errors for particular items don't have useful stack traces because the line of code in the stack trace doesn't tell you e.g. which array index caused the problem. This is particularly important in custom manifestation functions where we typically iterate over the tree forcing fields.
  2. It is currently not possible to write test cases in Jsonnet that check that the correct error is raised.
  3. It is not possible to detect using reflection that a field requires overriding, because we typically represent that with f: error "Must overide f" see std.mergePatch can't merge over error values #414.

Caveats:

  • Should it be possible to catch "runtime errors" like 1/0 or [1,2,3][10]? If not, how do we distinguish?
  • Should it be possible to catch major errors like exceeding stack size? If not, how do we distinguish?
  • It is clearly not possible to catch non-termination (halting problem).
  • Should error values be cached in thunks?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions