feature/cierres (#25)
Varios cambios Co-authored-by: Juan Pablo Vial <jpvialb@incoviba.cl> Reviewed-on: #25
This commit is contained in:
55
cli/src/Exception/Client/FastCGI.php
Normal file
55
cli/src/Exception/Client/FastCGI.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
namespace Incoviba\Exception\Client;
|
||||
|
||||
use Throwable;
|
||||
use Psr\Http\Client\ClientExceptionInterface;
|
||||
|
||||
|
||||
class FastCGI implements ClientExceptionInterface
|
||||
{
|
||||
public function __construct(protected ?Throwable $previous = null) {}
|
||||
|
||||
public function getMessage(): string
|
||||
{
|
||||
$message = "Could not send request";
|
||||
if ($this->previous !== null) {
|
||||
$message .= ": {$this->previous->getMessage()}";
|
||||
}
|
||||
return $message;
|
||||
}
|
||||
|
||||
public function getCode()
|
||||
{
|
||||
return $this->previous?->getCode() ?? 500;
|
||||
}
|
||||
|
||||
public function getFile(): string
|
||||
{
|
||||
return $this->previous?->getFile() ?? '';
|
||||
}
|
||||
|
||||
public function getLine(): int
|
||||
{
|
||||
return $this->previous?->getLine() ?? 0;
|
||||
}
|
||||
|
||||
public function getTrace(): array
|
||||
{
|
||||
return $this->previous?->getTrace() ?? [];
|
||||
}
|
||||
|
||||
public function getTraceAsString(): string
|
||||
{
|
||||
return $this->previous?->getTraceAsString() ?? '';
|
||||
}
|
||||
|
||||
public function getPrevious(): ?Throwable
|
||||
{
|
||||
return $this->previous;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getMessage();
|
||||
}
|
||||
}
|
18
cli/src/Exception/MQTT.php
Normal file
18
cli/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(string $message = "", int $code = 0, ?Throwable $previous = null)
|
||||
{
|
||||
$baseCode = 700;
|
||||
$code = $baseCode + $code;
|
||||
if ($message == "") {
|
||||
$message = "MQTT Exception";
|
||||
}
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
15
cli/src/Exception/MQTT/Create.php
Normal file
15
cli/src/Exception/MQTT/Create.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace Incoviba\Exception\MQTT;
|
||||
|
||||
use Throwable;
|
||||
use Incoviba\Exception\MQTT;
|
||||
|
||||
class Create extends MQTT
|
||||
{
|
||||
public function __construct(string $tube = '', string $payload = '', ?Throwable $previous = null)
|
||||
{
|
||||
$message = "Unable to create MQTT message: {$payload} in tube {$tube}";
|
||||
$code = 11;
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
15
cli/src/Exception/MQTT/Delete.php
Normal file
15
cli/src/Exception/MQTT/Delete.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace Incoviba\Exception\MQTT;
|
||||
|
||||
use Throwable;
|
||||
use Incoviba\Exception\MQTT;
|
||||
|
||||
class Delete extends MQTT
|
||||
{
|
||||
public function __construct(string $tube, int $jobId, ?Throwable $previous = null)
|
||||
{
|
||||
$message = "Could not delete job {$jobId} in tube {$tube}";
|
||||
$code = 13;
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
15
cli/src/Exception/MQTT/Read.php
Normal file
15
cli/src/Exception/MQTT/Read.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace Incoviba\Exception\MQTT;
|
||||
|
||||
use Throwable;
|
||||
use Incoviba\Exception\MQTT;
|
||||
|
||||
class Read extends MQTT
|
||||
{
|
||||
public function __construct(string $tube, ?Throwable $previous = null)
|
||||
{
|
||||
$message = "Error reading from tube {$tube}";
|
||||
$code = 10;
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
14
cli/src/Exception/MQTT/UnknownTransport.php
Normal file
14
cli/src/Exception/MQTT/UnknownTransport.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace Incoviba\Exception\MQTT;
|
||||
|
||||
use Incoviba\Exception\MQTT;
|
||||
use Throwable;
|
||||
|
||||
class UnknownTransport extends MQTT
|
||||
{
|
||||
public function __construct(string $transportName, ?Throwable $previous = null)
|
||||
{
|
||||
$message = "Unknown transport {$transportName}";
|
||||
parent::__construct($message, 1, $previous);
|
||||
}
|
||||
}
|
16
cli/src/Exception/MQTT/Update.php
Normal file
16
cli/src/Exception/MQTT/Update.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace Incoviba\Exception\MQTT;
|
||||
|
||||
use Throwable;
|
||||
use Incoviba\Exception\MQTT;
|
||||
|
||||
class Update extends MQTT
|
||||
{
|
||||
public function __construct(string $tube, string $payload, ?int $jobId = null, ?Throwable $previous = null)
|
||||
{
|
||||
$jobString = $jobId !== null ? " with jobId {$jobId}" : '';
|
||||
$message = "Could not update job{$jobString} with {$payload} in tube {$tube}";
|
||||
$code = 12;
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user