Try에서 JSON 구문 분석이 실패하면 catch 블록이 실행되지 않는 것 같습니다. 또한 과거에는 잘못된 형식의 JSON을 구문 분석하는 것이 이보다 더 문제가 되었다는 것을 알았습니다. 이 스레드 ) 그래서 해당 스레드에서 제안된 구문 분석 논리를 가져왔으며 이를 통해 Try가 예상대로 작동하도록 할 수 있었지만 Try가 catch를 실행하지 않는 매우 구체적인 시나리오가 있다는 점은 문제가 있는 것 같습니다.
암호:
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>산출:</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