feature/cierres (#25)
Varios cambios Co-authored-by: Juan Pablo Vial <jpvialb@incoviba.cl> Reviewed-on: #25
This commit is contained in:
22
app/src/Exception/AggregateException.php
Normal file
22
app/src/Exception/AggregateException.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace Incoviba\Exception;
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
class AggregateException extends Exception
|
||||
{
|
||||
public function __construct(array $exceptions, ?Throwable $previous = null)
|
||||
{
|
||||
$code = count($exceptions);
|
||||
$temp_arr = array_reverse($exceptions);
|
||||
$current = array_shift($temp_arr);
|
||||
$current->previous = $previous;
|
||||
foreach ($temp_arr as $exception) {
|
||||
$exception->previous = $current;
|
||||
$current = $exception;
|
||||
}
|
||||
$message = "Aggregate Exception";
|
||||
parent::__construct($message, $code, $current);
|
||||
}
|
||||
}
|
13
app/src/Exception/InvalidResult.php
Normal file
13
app/src/Exception/InvalidResult.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
namespace Incoviba\Exception;
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
class InvalidResult extends Exception
|
||||
{
|
||||
public function __construct(string $message = "", int $code = 404, ?Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
18
app/src/Exception/MQTT.php
Normal file
18
app/src/Exception/MQTT.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace Incoviba\Exception;
|
||||
|
||||
use Throwable;
|
||||
use Exception;
|
||||
|
||||
abstract class MQTT extends Exception
|
||||
{
|
||||
public function __construct($message = "", $code = 0, ?Throwable $previous = null)
|
||||
{
|
||||
$baseCode = 700;
|
||||
$code = $baseCode + $code;
|
||||
if ($message == "") {
|
||||
$message = "MQTT Exception";
|
||||
}
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
18
app/src/Exception/MQTT/MissingClient.php
Normal file
18
app/src/Exception/MQTT/MissingClient.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace Incoviba\Exception\MQTT;
|
||||
|
||||
use Throwable;
|
||||
use Incoviba\Exception\MQTT;
|
||||
|
||||
class MissingClient extends MQTT
|
||||
{
|
||||
public function __construct(string $host = '', ?Throwable $previous = null)
|
||||
{
|
||||
$message = 'Missing MQTT client';
|
||||
if ($host !== '') {
|
||||
$message = "{$message} for host {$host}";
|
||||
}
|
||||
$code = 1;
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
15
app/src/Exception/MQTT/MissingJob.php
Normal file
15
app/src/Exception/MQTT/MissingJob.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace Incoviba\Exception\MQTT;
|
||||
|
||||
use Throwable;
|
||||
use Incoviba\Exception\MQTT;
|
||||
|
||||
class MissingJob extends MQTT
|
||||
{
|
||||
public function __construct(?Throwable $previous = null)
|
||||
{
|
||||
$message = 'Missing MQTT job';
|
||||
$code = 10;
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
15
app/src/Exception/MQTT/RemoveJob.php
Normal file
15
app/src/Exception/MQTT/RemoveJob.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace Incoviba\Exception\MQTT;
|
||||
|
||||
use Throwable;
|
||||
use Incoviba\Exception\MQTT;
|
||||
|
||||
class RemoveJob extends MQTT
|
||||
{
|
||||
public function __construct(int $jobId, ?Throwable $previous = null)
|
||||
{
|
||||
$message = "Could not remove job {$jobId}";
|
||||
$code = 13;
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
15
app/src/Exception/MQTT/SetJob.php
Normal file
15
app/src/Exception/MQTT/SetJob.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace Incoviba\Exception\MQTT;
|
||||
|
||||
use Throwable;
|
||||
use Incoviba\Exception\MQTT;
|
||||
|
||||
class SetJob extends MQTT
|
||||
{
|
||||
public function __construct(string $payload, ?Throwable $previous = null)
|
||||
{
|
||||
$message = "Could not set job with {$payload}";
|
||||
$code = 11;
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ use Incoviba\Exception\ServiceActionFail;
|
||||
|
||||
class Create extends ServiceActionFail
|
||||
{
|
||||
public function __construct(string $service, Throwable $previous = null)
|
||||
public function __construct(string $service, ?Throwable $previous = null)
|
||||
{
|
||||
$action = 'create';
|
||||
$code = 1;
|
||||
|
@ -6,7 +6,7 @@ use Incoviba\Exception\ServiceActionFail;
|
||||
|
||||
class Delete extends ServiceActionFail
|
||||
{
|
||||
public function __construct(string $service, Throwable $previous = null)
|
||||
public function __construct(string $service, ?Throwable $previous = null)
|
||||
{
|
||||
$action = 'delete';
|
||||
$code = 4;
|
||||
|
@ -6,7 +6,7 @@ use Incoviba\Exception\ServiceActionFail;
|
||||
|
||||
class Read extends ServiceActionFail
|
||||
{
|
||||
public function __construct(string $service, Throwable $previous = null)
|
||||
public function __construct(string $service, ?Throwable $previous = null)
|
||||
{
|
||||
$action = 'read';
|
||||
$code = 2;
|
||||
|
@ -6,7 +6,7 @@ use Incoviba\Exception\ServiceActionFail;
|
||||
|
||||
class Update extends ServiceActionFail
|
||||
{
|
||||
public function __construct(string $service, Throwable $previous = null)
|
||||
public function __construct(string $service, ?Throwable $previous = null)
|
||||
{
|
||||
$action = 'edit';
|
||||
$code = 3;
|
||||
|
@ -6,7 +6,7 @@ use Throwable;
|
||||
|
||||
class ServiceActionFail extends Exception
|
||||
{
|
||||
public function __construct(string $service,string $action = "__invoke", int $code = 0, Throwable $previous = null)
|
||||
public function __construct(string $service,string $action = "__invoke", int $code = 0, ?Throwable $previous = null)
|
||||
{
|
||||
$message = "Action {$action} failed for Service {$service}.";
|
||||
$code = 700 + $code;
|
||||
|
Reference in New Issue
Block a user