-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExceptions.php
More file actions
100 lines (82 loc) · 2.1 KB
/
Exceptions.php
File metadata and controls
100 lines (82 loc) · 2.1 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
class MdtException extends Exception
{
public function type(){
return get_class();
}
public function __construct($msg)
{
dlog(['MdtException' => $msg]);
if(is_array($msg)){
$arr = $msg;
$msg = '';
foreach ($arr as $key => $value) {
$msg .= "$key => $value; ";
}
}
parent::__construct($msg);
}
}
class MdtLoginException extends MdtException
{
public function type(){
return 'Login exception';
}
private static $msg = "Mister sex login error: ";
public static function NoCredentialException($usern,$passwd,$BP,$msxurl){
$c = __CLASS__;
$msg .= $usern? '' : 'username not set ';
$msg .= $passwd? '' : 'password not set ';
$msg .= $BP? '' : 'BP not set ';
$msg .= $msxurl? '' : 'msx url not set';
return new $c("$msg<br>usern: $usern,<br>passwd: $passwd,<br>BP: $BP,<br>url: $msxurl");
}
public function __construct($msg)
{
parent::__construct(self::$msg.$msg);
}
}
class MdtRequestException extends MdtException
{
public function __construct($msg)
{
parent::__construct($msg);
}
}
class MdtProductException extends MdtException
{
public static function InsertingException($id, $postid = null){
$c = __CLASS__;
dlog($postid);
return new $c("$id: the product cannot be found or inserted");
}
public function __construct($msg)
{
parent::__construct("Error Inserting product ".$msg);
}
}
class MdtOrderException extends MdtException
{
public function __construct($msg, $productList, $order)
{
$msxTotal = count(isset($productList)? $productList : []);
$total = count($order->get_items());
$someProductsPhrase = 'rimuovere questi prodotti per proseguire:';
$allProductsPhrase = 'i prodotti scelti non sono disponibili al momento, ci dispiace per il disguido';
$str = ($msxTotal < $total)? $someProductsPhrase.'<ul><li>'.implode('</li><li> ', $products).'</li></ul>' : $allProductsPhrase;
$str = "<div class=\"msx-error\"><div>$str</div></div>";
$order->cancel_order( $msg );
parent::__construct($str);
}
}
/**
*
*/
class MdtStoppingException extends MdtException
{
function __construct()
{
parent::__construct('Stopping');
}
}
?>