[Chapel Merge] Work around an issue preventing users to catch errors from `JSON.fromJson`

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

Compare: Comparing 29e1c46d89ec2e3aa6a661859dee8b9c58eafcc4...6f27e17d35ca16ffde7f2dd9abdd42777c77e7f6 · chapel-lang/chapel · GitHub

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