-
Notifications
You must be signed in to change notification settings - Fork 8
/
Exceptions.inc
46 lines (36 loc) · 978 Bytes
/
Exceptions.inc
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
<?php
/**
* Thrown when there is a PHP -> Sikuli connection error.
*/
class PHPSikuliException extends Exception
{
}//end class
/**
* Thrown when there is a Sikuli error.
*/
class SikuliException extends Exception
{
}//end class
/**
* Thrown when image or text find operation fails.
*/
class FindFailedException extends SikuliException
{
public function __construct($message, $code=0, Exception $previous=null)
{
$match = array();
preg_match('/FindFailed: can not find.*\(([^\)]+)\)/mi', $message, $match);
$msg = 'Failed to find ';
if (empty($match) === FALSE) {
$msg .= $match[1];
} else {
preg_match('/FindFailed: can not find ([^\s]+)/mi', $message, $match);
if (empty($match) === FALSE) {
$msg .= $match[1];
} else {
$msg = $message;
}
}
parent::__construct($msg, $code, $previous);
}
}//end class