forbidden exception with body
This commit is contained in:
@@ -43,9 +43,9 @@ class Error extends InternalServerError implements HasBody
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
||||
public static function createWithBody(string $reason, string $body): self
|
||||
public static function createWithBody(string $message, string $body): self
|
||||
{
|
||||
$exception = new static($reason);
|
||||
$exception = new static($message);
|
||||
|
||||
$exception->body = $body;
|
||||
|
||||
|
||||
@@ -29,10 +29,37 @@
|
||||
|
||||
namespace Espo\Core\Exceptions;
|
||||
|
||||
class Forbidden extends \Exception
|
||||
use Throwable;
|
||||
use Exception;
|
||||
|
||||
class Forbidden extends Exception implements HasBody
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $code = 403;
|
||||
|
||||
/**
|
||||
* @var ?string
|
||||
*/
|
||||
private $body = null;
|
||||
|
||||
final public function __construct(string $message = '', int $code = 0, Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
||||
public static function createWithBody(string $message, string $body): self
|
||||
{
|
||||
$exception = new static($message);
|
||||
|
||||
$exception->body = $body;
|
||||
|
||||
return $exception;
|
||||
}
|
||||
|
||||
public function getBody(): ?string
|
||||
{
|
||||
return $this->body;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user