-
Notifications
You must be signed in to change notification settings - Fork 1
/
usage.example.php
64 lines (53 loc) · 2.12 KB
/
usage.example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
// -------------------------------------------------------
// Example 1: Use try-catch in bootstrap to define controlled behaviour!
// Initialize Exception Handling
try {
// Your bootstrap code!
// Just some stupid code examples
$a = 1;
$a ++;
// Throw exception anywhere within the code...
throw new Exception("Dummy Exception 1: Log only!");
} catch (Exception $e) {
// Handle exceptions using PHPCeption.
require_once 'PHPCeption/PHPCeption.php';
$phpceptionObj = PHPCeption_PHPCeption::createInstance();
require_once 'PHPCeption/Configurations/LogOnly.php';
$phpceptionObj->handle($e, PHPCeption_Configurations_LogOnly::createInstance());
}
// Notice: Code after catch will be executed!
// ----------------------------------------------------------------------
// Example 2: Use try-catch in bootstrap to define controlled behaviour!
// Initialize Exception Handling
try {
// Your bootstrap code!
// Just some stupid code examples
$a = 1;
$a ++;
// Throw exception anywhere within the code...
throw new Exception("Dummy Exception 2: NoDisplay (Log+Notify only!)");
} catch (Exception $e) {
// Handle exceptions using PHPCeption.
require_once 'PHPCeption/PHPCeption.php';
$phpceptionObj = PHPCeption_PHPCeption::createInstance();
require_once 'PHPCeption/Configurations/NoDisplay.php';
$phpceptionObj->handle($e, PHPCeption_Configurations_NoDisplay::createInstance());
}
// Notice: Code after catch will be executed!
// ----------------------------------------------------------------------
// Example 3: Define exception handler!
// Set this at the very beginning of your project!`
// Notice: After the Exception has been handled by this function, execution is
// finally aborted.
function handle_exception (Exception $e)
{
// Handle exceptions using PHPCeption.
require_once 'PHPCeption/PHPCeption.php';
$phpceptionObj = PHPCeption_PHPCeption::createInstance();
$phpceptionObj->handle($e);
}
set_exception_handler('handle_exception');
// Throw exception
throw new Exception("Dummy Exception 3");
//Notice: Following code will NOT be executed!