If I define a simple dataset and a simple function to apply to that data set:
data = Dataset[{<|"a" -> 1 , "b" -> 2, "c" -> 3|>,
<|"a" -> 4 , "b" -> 5, "c" -> -6|>,
<|"a" -> 7 , "b" -> 8, "c" -> 9|>}];
myValue[assoc_] := Module[{a = assoc},
myValue::errneg = "`1` is negative";
If[a["c"] < 0, Message[myValue::errneg, ToString[a["c"]]];
Return[a["b"]], Return[a["c"]]]
]
there is a failure behavior of the Message function I do not understand when applying the function to all rows of the dataset:
data[All, myValue]
The result is the myValue::errneg message wrapped in a Failure:
Failure[myValue,
Association[
"MessageTemplate" :> MessageName[myValue, "errneg"],
"MessageParameters" -> {"-6"}]]
This failure message is not returned when calling the myValue function with an association:
myValue[data[2]]
myValue::errneg: -6 is negative
Is there an explanation for this behavior (why is the call to Message generating a failure)?