Search code examples
exceptionrakuautovivification

perl6 Catching non-fatal exceptions in autovivification


I am running analysis on about 10000 lines of numbers, and some of the lines give me errors: "Use of uninitialized value of type Any in numeric context". I am trying to catch this error to see which lines are causing the problem. However, the X::TypeCheck, and other X::* classes don't seem to do effective catching autovivification of Nil or Any. E.g.:

try { say Any + 1; CATCH { default { say "oh-no"; } }; }

still gives me answer of "1" after printing out the warning message and does not say "oh-no" that I want.

What is the proper way to catch these non-fatal autovivification errors? And by the way, is there a nuclear-powered perl6 debugger?

Thank you very much !!!

lisprog


Solution

  • Use quietly and CONTROL instead of try and CATCH:

    quietly { say Any + 1; CONTROL { default { say "oh-no" } } }