#CALC!: an op that threw
#CALC! means that an op threw an exception, or gave no value. Vex catches the exception and makes it an error value. Thus the evaluation stays total.
app("parseWeight", ref("name"))| origin | A | B | C | D |
|---|---|---|---|---|
| result | #CALC! threw | #CALC! threw | #CALC! threw | #CALC! threw |
The program applies the free function parseWeight to the name of the box. No domain of the program accepts a string, so the interpreter uses the free function. The function throws, and the result is #CALC!.
| Kind | Cause |
|---|---|
threw |
An op, a free function, an extension handler, a fromScalar lift or a valid check threw an exception. A field read through a getter that throws also gives this kind. |
undefined-result |
An op gave undefined or null. |
For the kind threw, the error keeps the exception in the field thrown:
const r = chain.result("A");if (!r.ok && r.error.kind === "threw") console.error(r.error.thrown);The types cannot prevent #CALC!, because the code of the op decides when it throws.
The fix
Section titled “The fix”- Find why the op throws. The field
thrownholds the exception, and the fieldopholds the name of the op. - Give an op a value for each input that its domain accepts. Use an error value or a
validcheck, not an exception. - Give a fallback with
ifErrorfor an op that can fail.
Refer to error values for the other codes.