Move qgsfunction to qgis.core.

Add new register_function method when not using decorator
Wrap function call in try block to catch and report errors