File tree Expand file tree Collapse file tree 3 files changed +47
-4
lines changed Expand file tree Collapse file tree 3 files changed +47
-4
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## [ Unreleased]
4
4
5
+ * Use custom LoaderException for context loading errors.
6
+
5
7
## [ 4.1.9] - 2017-07-12
6
8
7
9
* Various code cleanups.
Original file line number Diff line number Diff line change 9
9
10
10
namespace PhpMyAdmin \SqlParser ;
11
11
12
+ use PhpMyAdmin \SqlParser \Exceptions \LoaderException ;
13
+
12
14
/**
13
15
* Holds the configuration of the context that is currently used.
14
16
*
@@ -443,7 +445,7 @@ public static function isSeparator($str)
443
445
* @param string $context name of the context or full class name that
444
446
* defines the context
445
447
*
446
- * @throws \Exception if the specified context doesn't exist
448
+ * @throws LoaderException if the specified context doesn't exist
447
449
*/
448
450
public static function load ($ context = '' )
449
451
{
@@ -455,8 +457,9 @@ public static function load($context = '')
455
457
$ context = self ::$ contextPrefix . $ context ;
456
458
}
457
459
if (!class_exists ($ context )) {
458
- throw new \Exception (
459
- 'Specified context (" ' . $ context . '") does not exist. '
460
+ throw new LoaderException (
461
+ 'Specified context (" ' . $ context . '") does not exist. ' ,
462
+ $ context
460
463
);
461
464
}
462
465
self ::$ loadedContext = $ context ;
@@ -491,7 +494,7 @@ public static function loadClosest($context = '')
491
494
try {
492
495
// Trying to load the new context.
493
496
static ::load ($ context );
494
- } catch (\ Exception $ e ) {
497
+ } catch (LoaderException $ e ) {
495
498
// If it didn't work, we are looking for a new one and skipping
496
499
// over to the next generation that will try the new context.
497
500
$ context = preg_replace (
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /**
4
+ * Exception thrown by the lexer.
5
+ */
6
+
7
+ namespace PhpMyAdmin \SqlParser \Exceptions ;
8
+
9
+ /**
10
+ * Exception thrown by the lexer.
11
+ *
12
+ * @category Exceptions
13
+ *
14
+ * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+
15
+ */
16
+ class LoaderException extends \Exception
17
+ {
18
+ /**
19
+ * The failed load name.
20
+ *
21
+ * @var string
22
+ */
23
+ public $ name ;
24
+
25
+ /**
26
+ * Constructor.
27
+ *
28
+ * @param string $msg the message of this exception
29
+ * @param string $ch the character that produced this exception
30
+ * @param int $pos the position of the character
31
+ * @param int $code the code of this error
32
+ */
33
+ public function __construct ($ msg = '' , $ name = '' , $ code = 0 )
34
+ {
35
+ parent ::__construct ($ msg , $ code );
36
+ $ this ->name = $ name ;
37
+ }
38
+ }
You can’t perform that action at this time.
0 commit comments