In general, we should keep in mind that function evaluations may fail or return exceptional values. A robust and reliable solver must handle such cases properly.
In this way, the function evaluations are wrapped using a try ... catch ... so that exceptions will be taken care of. The solvers will not crash even if the function evaluation fails.
See the discussion at
https://github.com/libprima/prima/issues/90 ,
which is copy-pasted below.
See also my elaboration at https://github.com/libprima/prima/issues/80#issuecomment-1727134736