Skip to content

Commit

Permalink
Exception management
Browse files Browse the repository at this point in the history
Add internal dependency
  • Loading branch information
EMMANUEL HAVET committed Oct 25, 2022
1 parent 59db1db commit 5c56bab
Show file tree
Hide file tree
Showing 18 changed files with 24 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/quickcost.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace ladromelaboratoire\chronopostws;
use ladromelaboratoire\chronopostws\wsdata\wsregex;
use ladromelaboratoire\chronopostws\wsdata\wsdata;
use ladromelaboratoire\chronopostws\exceptions\wsdataexception;
// use ladromelaboratoire\chronopostws\wsdata\wsquickcostvalue;


Expand Down
1 change: 1 addition & 0 deletions src/shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use ladromelaboratoire\chronopostws\wsdata\wsesdvalue;
use ladromelaboratoire\chronopostws\wsdata\wscustomsvalue;
use ladromelaboratoire\chronopostws\wsdata\wsscheduledvalue;
use ladromelaboratoire\chronopostws\exceptions\wsdataexception;

class shipment extends wsdata {

Expand Down
1 change: 1 addition & 0 deletions src/tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use ladromelaboratoire\chronopostws\wsdata\wsregex;
use ladromelaboratoire\chronopostws\wsdata\wsdata;
use ladromelaboratoire\chronopostws\wsdata\wscancelskybillvalue;
use ladromelaboratoire\chronopostws\exceptions\wsdataexception;


class tracking {
Expand Down
1 change: 1 addition & 0 deletions src/wsdata/wsappointmentvalue.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace ladromelaboratoire\chronopostws\wsdata;
use ladromelaboratoire\chronopostws\wsdata\wsregex;
use ladromelaboratoire\chronopostws\wsdata\wsdata;
use ladromelaboratoire\chronopostws\exceptions\wsdataexception;

class wsappointmentvalue extends wsdata {

Expand Down
1 change: 1 addition & 0 deletions src/wsdata/wsarticlesvalue.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace ladromelaboratoire\chronopostws\wsdata;
use ladromelaboratoire\chronopostws\wsdata\wsregex;
use ladromelaboratoire\chronopostws\wsdata\wsdata;
use ladromelaboratoire\chronopostws\exceptions\wsdataexception;

class wsarticlesvalue extends wsdata {

Expand Down
1 change: 1 addition & 0 deletions src/wsdata/wscancelskybillvalue.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace ladromelaboratoire\chronopostws\wsdata;
use ladromelaboratoire\chronopostws\wsdata\wsregex;
use ladromelaboratoire\chronopostws\wsdata\wsdata;
use ladromelaboratoire\chronopostws\exceptions\wsdataexception;

class wscancelskybillvalue extends wsdata {

Expand Down
1 change: 1 addition & 0 deletions src/wsdata/wscustomervalue.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace ladromelaboratoire\chronopostws\wsdata;
use ladromelaboratoire\chronopostws\wsdata\wsregex;
use ladromelaboratoire\chronopostws\wsdata\wsdata;
use ladromelaboratoire\chronopostws\exceptions\wsdataexception;

class wscustomervalue extends wsdata {

Expand Down
1 change: 1 addition & 0 deletions src/wsdata/wscustomsvalue.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use ladromelaboratoire\chronopostws\wsdata\wsregex;
use ladromelaboratoire\chronopostws\wsdata\wsdata;
use ladromelaboratoire\chronopostws\wsdata\wsarticlesvalue;
use ladromelaboratoire\chronopostws\exceptions\wsdataexception;

class wscustomsvalue extends wsdata {

Expand Down
13 changes: 7 additions & 6 deletions src/wsdata/wsdata.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace ladromelaboratoire\chronopostws\wsdata;
use ladromelaboratoire\chronopostws\wsdata\wsregex;
use ladromelaboratoire\chronopostws\exceptions\wsdataexception;

abstract class wsdata {

Expand All @@ -20,7 +21,7 @@ public function __construct ($useExceptions = false) {
protected function setVariableReg (&$variable, $data, $reg) {
$check = preg_match($reg, $data);
if ($check === false || $check === 0) {
if ($this->useExceptions) throw new Exception(__METHOD__ . " - $data does not match webservice requirement according to regex $reg");
if ($this->useExceptions) throw new wsdataexception(__METHOD__ . " - $data does not match webservice requirement according to regex $reg");
//echo ("<pre>souci avec la valeur $data et la règle $reg</pre>\r\n");
return false;
}
Expand All @@ -35,7 +36,7 @@ protected function setVariableInt (&$variable, $data) {
return true;
}
else {
if ($this->useExceptions) throw new Exception(__METHOD__ . " - $data does not match webservice requirement as int");
if ($this->useExceptions) throw new wsdataexception(__METHOD__ . " - $data does not match webservice requirement as int");
// echo ("<pre>$data n'est pas un entier</pre>\r\n");
return false;
}
Expand All @@ -46,7 +47,7 @@ protected function setVariableFloat (&$variable, $data) {
return true;
}
else {
if ($this->useExceptions) throw new Exception(__METHOD__ . " - $data does not match webservice requirement as float");
if ($this->useExceptions) throw new wsdataexception(__METHOD__ . " - $data does not match webservice requirement as float");
// echo ("<pre>$data n'est pas un float</pre>\r\n");
return false;
}
Expand All @@ -57,7 +58,7 @@ protected function setVariableBool (&$variable, $data) {
return true;
}
else {
if ($this->useExceptions) throw new Exception(__METHOD__ . " - $data does not match webservice requirement as boolean");
if ($this->useExceptions) throw new wsdataexception(__METHOD__ . " - $data does not match webservice requirement as boolean");
// echo ("<pre>$data n'est pas un booleen</pre>\r\n");
return false;
}
Expand All @@ -70,12 +71,12 @@ public function loadArray($array) {
$this->$func($value);
}
else {
if ($this->useExceptions) throw new Exception(__METHOD__ . " - Property and/or setter method $key does not exist in object");
if ($this->useExceptions) throw new wsdataexception(__METHOD__ . " - Property and/or setter method $key does not exist in object");
}
}
}
else {
if ($this->useExceptions) throw new Exception(__METHOD__ . " - not an associative array passed as parameter");
if ($this->useExceptions) throw new wsdataexception(__METHOD__ . " - not an associative array passed as parameter");
}
}

Expand Down
1 change: 1 addition & 0 deletions src/wsdata/wsheadervalue.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace ladromelaboratoire\chronopostws\wsdata;
use ladromelaboratoire\chronopostws\wsdata\wsregex;
use ladromelaboratoire\chronopostws\wsdata\wsdata;
use ladromelaboratoire\chronopostws\exceptions\wsdataexception;

class wsheadervalue extends wsdata {

Expand Down
1 change: 1 addition & 0 deletions src/wsdata/wslabelrecoveryvalue.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace ladromelaboratoire\chronopostws\wsdata;
use ladromelaboratoire\chronopostws\wsdata\wsregex;
use ladromelaboratoire\chronopostws\wsdata\wsdata;
use ladromelaboratoire\chronopostws\exceptions\wsdataexception;

class wslabelrecoveryvalue extends wsdata {

Expand Down
1 change: 1 addition & 0 deletions src/wsdata/wsrecipientvalue.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace ladromelaboratoire\chronopostws\wsdata;
use ladromelaboratoire\chronopostws\wsdata\wsregex;
use ladromelaboratoire\chronopostws\wsdata\wsdata;
use ladromelaboratoire\chronopostws\exceptions\wsdataexception;

class wsrecipientvalue extends wsdata {

Expand Down
1 change: 1 addition & 0 deletions src/wsdata/wsscheduledvalue.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use ladromelaboratoire\chronopostws\wsdata\wsregex;
use ladromelaboratoire\chronopostws\wsdata\wsdata;
use ladromelaboratoire\chronopostws\wsdata\wsappointmentvalue;
use ladromelaboratoire\chronopostws\exceptions\wsdataexception;

class wsscheduledvalue extends wsdata {

Expand Down
1 change: 1 addition & 0 deletions src/wsdata/wssearchpodvalue.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace ladromelaboratoire\chronopostws\wsdata;
use ladromelaboratoire\chronopostws\wsdata\wsregex;
use ladromelaboratoire\chronopostws\wsdata\wsdata;
use ladromelaboratoire\chronopostws\exceptions\wsdataexception;

class wssearchpodvalue extends wsdata {

Expand Down
1 change: 1 addition & 0 deletions src/wsdata/wsshippervalue.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace ladromelaboratoire\chronopostws\wsdata;
use ladromelaboratoire\chronopostws\wsdata\wsregex;
use ladromelaboratoire\chronopostws\wsdata\wsdata;
use ladromelaboratoire\chronopostws\exceptions\wsdataexception;

class wsshippervalue extends wsdata {

Expand Down
1 change: 1 addition & 0 deletions src/wsdata/wsskybillparamsvalue.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace ladromelaboratoire\chronopostws\wsdata;
use ladromelaboratoire\chronopostws\wsdata\wsregex;
use ladromelaboratoire\chronopostws\wsdata\wsdata;
use ladromelaboratoire\chronopostws\exceptions\wsdataexception;

class wsskybillparamsvalue extends wsdata {

Expand Down
1 change: 1 addition & 0 deletions src/wsdata/wsskybillvalue.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace ladromelaboratoire\chronopostws\wsdata;
use ladromelaboratoire\chronopostws\wsdata\wsregex;
use ladromelaboratoire\chronopostws\wsdata\wsdata;
use ladromelaboratoire\chronopostws\exceptions\wsdataexception;

class wsskybillvalue extends wsdata {

Expand Down
1 change: 1 addition & 0 deletions src/wsdata/wstrackingoneparcelvalue.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace ladromelaboratoire\chronopostws\wsdata;
use ladromelaboratoire\chronopostws\wsdata\wsregex;
use ladromelaboratoire\chronopostws\wsdata\wsdata;
use ladromelaboratoire\chronopostws\exceptions\wsdataexception;

class wstrackingoneparcelvalue extends wsdata {

Expand Down

0 comments on commit 5c56bab

Please sign in to comment.