I'm not sure I understand this pattern.  Is it that you're checking the function exists and only calling it if thats the case?

It seems like this could fail silently in a bad way.  For example, if you expect an on_failure call to be made isn't it better to throw an exception (display an error) when that function doesn't exist rather than just skipping that call.