How to prevent saving in SuiteCRM

Hello,

I need to develop a module which checks if an event is overlapping other one.

When some conditions are met, the events should be considered overlapped. When this happens the saving process should not be carried on and the user should be warned.

I’m doing this with the logic hook before_save.

In logic_hooks of the module

$hook_array['before_save'] = Array();
$hook_array['before_save'][] = Array(
    //Processing index. For sorting the array.
    1,

    //Label. A string value to identify the hook.
    'before_save example',

    //The PHP file where your class is located.
    'custom/modules/Module/logic_hooks_class.php',

    //The class the method is in.
    'logic_hooks_class',

    //The method to call.
    'before_save_method'
);

The file β€œlogic_hooks_class.php” has these code:

<?php

    if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

    class logic_hooks_class
    //  extends SugarApi // Tried to use SugarAPI as seen googling, but these class does not exist in SuiteCRM
    {
        function before_save_method($bean, $event, $arguments)
        {
          throw new SugarApiException("Error Message to TEST!", null, 'Meetings', 550); // logically if SugarApi is not extenden we can't use these Exception
        }
    }

?>

Anyone knows how to implement these behaviour or how to use SuiteCRM Exceptions?

Thanks in advance.