forbidden exception with body

This commit is contained in:
Yuri Kuznetsov
2022-03-28 14:38:03 +03:00
parent 01e0d51c0a
commit bdfe6b5e23
2 changed files with 30 additions and 3 deletions
+2 -2
View File
@@ -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;
+28 -1
View File
@@ -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;
}
}