You can safely throw exceptions at any point while writing your own SearchEngine. Errors will be caught
by the SearchThrowableHandler
class and a friendly message will be shown to the user.
If your SuiteCRM instance is in developer mode a detailed exception page will be shown, making it easier for you to
debug.
In the example below the same erroneous query is shown with developer mode
on (left) and off (right).
If you wish to directly show an error message to the user, you can throw a SearchUserFriendlyException
. Remember to
use the translation framework if you want the error to be localised, and never show details that are (too) technical.
Example of throwing a user-friendly error message:
throw new SearchUserFriendlyException(translate('LBL_ERROR_MESSAGE_INVALID_QUERY'));