Branch: refs/heads/main
Revision: b497cb2206bf4be5d5691b9ee3a5a0f317d1233f
Author: e-kayrakli
Link: Work around an issue preventing users to catch errors from `JSON.fromJson` by e-kayrakli · Pull Request #26656 · chapel-lang/chapel · GitHub
Log Message:
Work around an issue preventing users to catch errors from JSON.fromJson
(#26656)
JSON.fromJson
used the pattern:
return reader.read(MyType);
this results in calling a compiler-generated deserialization initializer
that does not throw. While working on Arkouda checkpointing that led to
writing code in which there are uncatchable errors. I worked this around
in Arkouda for the time being by having my own fromJson
-like helper.
This PR adjusts the standard fromJson
to use the following pattern,
from which an error can be thrown and caught as expected:
var ret: MyType;
reader.read(ret);
return ret;
Test:
- local
Diff:
M modules/standard/JSON.chpl
A test/io/serializers/jsonHelpers/fromJsonThrows.chpl
A test/io/serializers/jsonHelpers/fromJsonThrows.cleanfiles
A test/io/serializers/jsonHelpers/fromJsonThrows.good
A test/io/serializers/jsonHelpers/fromJsonThrows.preexec
https://github.com/chapel-lang/chapel/pull/26656.diff