ProcFu Help
Search
⚠️

Error Handling

All ProcFu scripts are available as native functions in ProcScript.

Eg:

text = webpage_text_regex(url, "(.*)")

And if that script fails for any reason, you're left with a null return and an error in your GlobiFlow logs.

Error: HTTP Returned Code 500

You can change this behaviour by specifying your own error handler function, eg:

function my_error_handler(error_message, line) {
	yield ""
}
ini_set("error_handler", "my_error_handler")
text = webpage_text_regex(url, "(.*)")

In this case, if webpage_text_regex fails, the script will return "" and no error will be logged.

Note that in the above case, the error handler function uses yield to return a value instead of return because it's in a function and we want to bypass the regular function return and return the value back to the calling process, stopping execution.

Another good use-case is to selectively bypass errors only in the instances where we want this behaviour, and restore regular exceptions in other cases. Eg:

function null_error_handler(error_message, line) {
}
ini_set("error_handler", "null_error_handler")
text = webpage_text_regex(url, "(.*)")
if ( text == null ) {
	// code
} else {
	// code
}
ini_set("error_handler", false)
// next error will cause a normal exception

You can also selectively throw errors depending on the message, eg:

function my_error_handler(error_message, line) {
	// if the error message contains "invalid" throw an exception
	if ( stristr(error_message, "invalid") ) {
		throw error_message
	}
	// if the error message does not contain "invalid" ignore it
}

ini_set("error_handler", "my_error_handler")
text = webpage_text_regex(url, "(.*)")
if ( text == null ) {
	// it failed but not because of "invalid"
} else {
	// it worked
}

(c) 2024 ProcFu for Podio - by Globi | Join the Discussion in our Podio Workspace.