PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.16
VikBooking Hotel Booking Engine & PMS v1.8.16
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
← All changes | libraries/bc/error.php +100 -0 1.6.3 → 1.8.16 View file →
@@ -1,0 +1,100 @@
1 +<?php
2 +/**
3 + * @package VikBooking - Libraries
4 + * @subpackage bc (backward compatibility)
5 + * @author E4J s.r.l.
6 + * @copyright Copyright (C) 2018 E4J s.r.l. All Rights Reserved.
7 + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 + * @link https://vikwp.com
9 + */
10 +
11 +// No direct access
12 +defined('ABSPATH') or die('No script kiddies please!');
13 +
14 +if (!class_exists('VikError'))
15 +{
16 + /**
17 + * Class used to implement the functionalities of JError.
18 + *
19 + * @since 1.0
20 + */
21 + abstract class VikError
22 + {
23 + /**
24 + * Wrapper error method for the handleError() method.
25 + *
26 + * @throws Exception Throws an exception only when the code is not null.
27 + *
28 + * @param string $code The application-internal error code for this error.
29 + * @param string $msg The error message, which may also be shown the user if need be.
30 + *
31 + * @return JException|string $error The thrown JException object
32 + *
33 + * @see JError::handleError()
34 + */
35 + public static function raiseError($code, $message)
36 + {
37 + return self::handleError(E_ERROR, $code, $message);
38 + }
39 +
40 + /**
41 + * Wrapper warning method for the handleError() method.
42 + *
43 + * @throws Exception Throws an exception only when the code is not null.
44 + *
45 + * @param string $code The application-internal error code for this error.
46 + * @param string $msg The error message, which may also be shown the user if need be.
47 + *
48 + * @return JException|string $error The thrown JException object
49 + *
50 + * @see JError::handleError()
51 + */
52 + public static function raiseWarning($code, $message)
53 + {
54 + return self::handleError(E_WARNING, $code, $message);
55 + }
56 +
57 + /**
58 + * Wrapper notice method for the handleError() method.
59 + *
60 + * @throws Exception Throws an exception only when the code is not null.
61 + *
62 + * @param string $code The application-internal error code for this error.
63 + * @param string $msg The error message, which may also be shown the user if need be.
64 + *
65 + * @return JException|string $error The thrown JException object
66 + *
67 + * @see JError::handleError()
68 + */
69 + public static function raiseNotice($code, $message)
70 + {
71 + return self::handleError(E_NOTICE, $code, $message);
72 + }
73 +
74 + /**
75 + * Handle the error in the proper way.
76 + *
77 + * @throws Exception Throws an exception only when the code is not null.
78 + *
79 + * @param string $level The error level - use any of PHP's own error levels for.
80 + * this: E_ERROR, E_WARNING, E_NOTICE, E_USER_ERROR,
81 + * E_USER_WARNING, E_USER_NOTICE.
82 + * @param string $code The application-internal error code for this error
83 + * @param string $msg The error message, which may also be shown the user if need be.
84 + *
85 + * @return JException|string $error The thrown JException object
86 + *
87 + */
88 + protected static function handleError($level, $code, $message)
89 + {
90 + if (!empty($code))
91 + {
92 + throw new Exception($message, $code);
93 + }
94 +
95 + JFactory::getApplication()->enqueueMessage($message, ($level == E_NOTICE ? 'notice' : 'error'));
96 +
97 + return '';
98 + }
99 + }
100 +}