How can I modify the `f` function to handle exceptions from the `outer` function properly

join shbcf.ru