-
Notifications
You must be signed in to change notification settings - Fork 458
Consider try / catch functionality #415
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
Comments
@mikedanese and @yugui for unit testing |
It's notable that all 3 motivations currently have workarounds that require only limited try / catch functionality:
|
Currently it fails with Thanks, |
It was discussed the possibility of optional extVars in #304. The decision was that they are a bad idea for discoverability reasons. It's likely to encourage harmful patterns like depending on implicit set of extVars in libraries. |
Hi @gaurav517
If you don't mind me suggesting a solution to a slightly different problem which exists if one switches from extVar to TLAs: Instead of {
foo: std.extVar("foo")
} Refactor to be: function (foo = 42) {
foo: foo
} Exercising like:
Or, to get a number instead of a string
Alternatively, you could set the TLA in the function definition as I had to do a bit of refatoring when I switched from extVars to TLAs but in the end it was well worth it. |
Thanks. switching to TLA would need wrapping in
Now I have a jsonnet that uses that library:
and it works. But if we wrap it with
then it won't work, because its expecting |
You don't need the So in your case it will be just:
|
Thanks. yeah, getting used to syntax slowly. :) |
Uh oh!
There was an error while loading. Please reload this page.
Currently
error "foo"
is like throwing an exception, but there is no way to catch the exception.Motivations for "catch":
f: error "Must overide f"
see std.mergePatch can't merge over error values #414.Caveats:
1/0
or[1,2,3][10]
? If not, how do we distinguish?The text was updated successfully, but these errors were encountered: