feature/cierres (#25)

Varios cambios

Co-authored-by: Juan Pablo Vial <jpvialb@incoviba.cl>
Reviewed-on: #25
This commit is contained in:
2025-07-22 13:18:00 +00:00
parent ba57cad514
commit 307f2ac7d7
418 changed files with 20045 additions and 984 deletions

View 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);
}
}

View 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);
}
}

View 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);
}
}

View 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);
}
}

View 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);
}
}

View 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);
}
}

View 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);
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;