New Issue: Confusing error message for exceptions caught be standalone writef\readf

18296, "stonea", "Confusing error message for exceptions caught be standalone writef\readf", "2021-08-25T21:36:27Z"

Currently we are catching exceptions from writef and readf and not allowing them to escape. This is specific to the standalone versions of writef`readf`, not the methods on channels. I believe this is by design, maybe @bradcray or @dlongnecke-cray can elaborate on why.

Anyway, this is confusing because if an exception is thrown the user will get an error like this (assuming CHPL_DEVELOPER is unset), which makes it sound like they could wrap their code in a try\catch block to deal with the exception:

uncaught IllegalArgumentError: Can not perform Chapel write of multidimensional array.
  foo.chpl:3: thrown here
  foo.chpl:3: uncaught here

This specific error message requires that we first merge Array module review --- error on multidim array print by stonea · Pull Request #18262 · chapel-lang/chapel · Gi and then try and compile the following:

use IO;
var B:[1..9, 1..9] int;
writef("%ht\n", B);

There are a couple of "solutions" I see:

  • Have these exceptions escape writef`readf`. Although I suppose there's a reason we designed them not to though.
  • Catch exceptions in writef`readfand represent them to the user as an error. Basically do something like this in thewritef` function:
try {
 // body of writef
} catch e {
  error("Issue encountered while conducting writef: ", e.message);
}