formula recordService throw message body
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
namespace Espo\Core\Formula\Functions\RecordServiceGroup;
|
||||
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Exceptions\Error\Body;
|
||||
use Espo\Core\Formula\ArgumentList;
|
||||
use Espo\Core\Formula\Exceptions\Error;
|
||||
use Espo\Core\Formula\Exceptions\ExecutionException;
|
||||
@@ -49,13 +50,13 @@ class ThrowBadRequestType extends BaseFunction
|
||||
$this->throwError("Can be called only from API script.");
|
||||
}
|
||||
|
||||
$statusText = isset($args[0]) ? $this->evaluate($args[0]) : '';
|
||||
$message = isset($args[0]) ? $this->evaluate($args[0]) : '';
|
||||
$body = isset($args[1]) ? $this->evaluate($args[1]) : null;
|
||||
|
||||
if ($body !== null) {
|
||||
throw BadRequest::createWithBody($statusText, Json::encode($body));
|
||||
throw BadRequest::createWithBody($message, Json::encode($body));
|
||||
}
|
||||
|
||||
throw new BadRequest($statusText);
|
||||
throw BadRequest::createWithBody($message, Body::create()->withMessage($message));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace Espo\Core\Formula\Functions\RecordServiceGroup;
|
||||
|
||||
use Espo\Core\Exceptions\Conflict;
|
||||
use Espo\Core\Exceptions\ConflictSilent;
|
||||
use Espo\Core\Exceptions\Error\Body;
|
||||
use Espo\Core\Formula\ArgumentList;
|
||||
use Espo\Core\Formula\Exceptions\Error;
|
||||
use Espo\Core\Formula\Exceptions\ExecutionException;
|
||||
@@ -50,13 +51,13 @@ class ThrowConflictType extends BaseFunction
|
||||
$this->throwError("Can be called only from API script.");
|
||||
}
|
||||
|
||||
$statusText = isset($args[0]) ? $this->evaluate($args[0]) : '';
|
||||
$message = isset($args[0]) ? $this->evaluate($args[0]) : '';
|
||||
$body = isset($args[1]) ? $this->evaluate($args[1]) : null;
|
||||
|
||||
if ($body !== null) {
|
||||
throw ConflictSilent::createWithBody($statusText, Json::encode($body));
|
||||
throw ConflictSilent::createWithBody($message, Json::encode($body));
|
||||
}
|
||||
|
||||
throw new ConflictSilent($statusText);
|
||||
throw ConflictSilent::createWithBody($message, Body::create()->withMessage($message));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Formula\Functions\RecordServiceGroup;
|
||||
|
||||
use Espo\Core\Exceptions\Error\Body;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\ForbiddenSilent;
|
||||
use Espo\Core\Formula\ArgumentList;
|
||||
@@ -50,13 +51,13 @@ class ThrowForbiddenType extends BaseFunction
|
||||
$this->throwError("Can be called only from API script.");
|
||||
}
|
||||
|
||||
$statusText = isset($args[0]) ? $this->evaluate($args[0]) : '';
|
||||
$message = isset($args[0]) ? $this->evaluate($args[0]) : '';
|
||||
$body = isset($args[1]) ? $this->evaluate($args[1]) : null;
|
||||
|
||||
if ($body !== null) {
|
||||
throw ForbiddenSilent::createWithBody($statusText, Json::encode($body));
|
||||
throw ForbiddenSilent::createWithBody($message, Json::encode($body));
|
||||
}
|
||||
|
||||
throw new ForbiddenSilent($statusText);
|
||||
throw ForbiddenSilent::createWithBody($message, Body::create()->withMessage($message));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user