Custom Function return type is void

Custom Function return type is void

For some reason, creating a Custom Function from a Button returns a string (which display in "Message Content" popup) but return nothing (void) from a Rule.  Is there a way to make the Custom Function either return a string or display a message in the next page (after Save or Edit) if an error occurs?