handle_exception
Overview
The handle_exception
logic hook executes when an exception is thrown.
Definition
function handle_exception($event, $exception){}
Arguments
Name | Type | Description |
---|---|---|
event | String | The current event |
exception | Object | The exception object |
Considerations
- This hook should not be used for any type of display output.
- You can retrieve the exception message by using
$exception->getMessage()
. All exception classes extend the PHP Exceptions class.
Change Log
Version | Note |
---|---|
6.4.4 | Added handle_exception hook |
Example
./custom/modules/logic_hooks.php
<?php
$hook_version = 1;
$hook_array = Array();
$hook_array['handle_exception'] = Array();
$hook_array['handle_exception'][] = Array(
//Processing index. For sorting the array.
1,
//Label. A string value to identify the hook.
'handle_exception example',
//The PHP file where your class is located.
'custom/modules/handle_exception_class.php',
//The class the method is in.
'handle_exception_class',
//The method to call.
'handle_exception_method'
);
?>
./custom/modules/handle_exception_class.php
<?php
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class handle_exception_class
{
function handle_exception_method($event, $exception)
{
//logic with $exception->getMessage()
}
}
?>