Vedo che quando Parse JSON fallisce in un Try, il blocco catch non sembra essere eseguito. Vedo anche che l'analisi di JSON malformato è stata più problematica di così in passato (vedi questo filo ), quindi ho preso la logica di analisi suggerita da quel thread, che mi consente di fare in modo che Try si comporti come previsto, ma sembra problematico che Try abbia questo scenario molto specifico in cui non esegue la cattura.
Codice:
someVar = Try(
Parse JSON("{{1}}"),
Print("in catch 1");
2;
);
someVar2 = Try(
Throw( "broke!" ),
Print("in catch 2");
2;
);
someVar3 = Try(
txt = Log Capture( result = Parse JSON( "{{1}}") );
If( Length( txt ),
Throw( txt ) // error message
);
result; // parsed JSON
,
Print("in catch 3");
2;
);
Print("someVar is:");
Print(someVar);
Print("someVar2 is:");
Print(someVar2);
Print("someVar3 is:");
Print(someVar3);</CODE></P><P>Produzione:</P><P> </P><P> </P><PRE><CODE class=" language-jsl">Unexpected "{". Perhaps there is a missing }.
Line 1 Column 2: {►{1}}
"someVar is:"
.
"someVar2 is:"
2
"someVar3 is:"
2