Calling Non-Existent UDF module doesn't throw error

I am using the execute API of the Java client to call a UDF. I want to make it future-proof so that if the UDF module is removed or deleted by anyone or if the function is called on a server where UDF is not registered. The way I am planning to do this is by first calling the UDF and expecting Aerospike to throw an error if the UDF does not exist, then in my application catch this error and call the API to register the UDF. BUt aerospike is not throwing the error when i try to call an UDF using the execute api.

Any way to handle this scenario?

You should re-register the UDF if there is a possibility of it being removed. Registering a UDF works even when the UDF already exists. Actually, for stream UDFs which need to exist on both client and server, registering before use is required if the client instance does not know of it.