Excepciones de servicios

This commit is contained in:
Juan Pablo Vial
2025-02-24 12:41:00 -03:00
parent 28bba8a438
commit a44bd610ad
5 changed files with 75 additions and 0 deletions

View File

@ -0,0 +1,15 @@
<?php
namespace Incoviba\Exception\ServiceAction;
use Throwable;
use Incoviba\Exception\ServiceActionFail;
class Create extends ServiceActionFail
{
public function __construct(string $service, Throwable $previous = null)
{
$action = 'create';
$code = 1;
parent::__construct($service, $action, $code, $previous);
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace Incoviba\Exception\ServiceAction;
use Throwable;
use Incoviba\Exception\ServiceActionFail;
class Delete extends ServiceActionFail
{
public function __construct(string $service, Throwable $previous = null)
{
$action = 'delete';
$code = 4;
parent::__construct($service, $action, $code, $previous);
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace Incoviba\Exception\ServiceAction;
use Throwable;
use Incoviba\Exception\ServiceActionFail;
class Read extends ServiceActionFail
{
public function __construct(string $service, Throwable $previous = null)
{
$action = 'read';
$code = 2;
parent::__construct($service, $action, $code, $previous);
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace Incoviba\Exception\ServiceAction;
use Throwable;
use Incoviba\Exception\ServiceActionFail;
class Update extends ServiceActionFail
{
public function __construct(string $service, Throwable $previous = null)
{
$action = 'edit';
$code = 3;
parent::__construct($service, $action, $code, $previous);
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace Incoviba\Exception;
use Exception;
use Throwable;
class ServiceActionFail extends Exception
{
public function __construct(string $service,string $action = "__invoke", int $code = 0, Throwable $previous = null)
{
$message = "Action {$action} failed for Service {$service}.";
$code = 700 + $code;
parent::__construct($message, $code, $previous);
}
}