PR review changes for exception publishing

This commit is contained in:
Matej Bačo 2024-01-26 12:07:08 +00:00
parent 50c2ebc950
commit c0ae2e6549
2 changed files with 4 additions and 11 deletions

View file

@ -613,7 +613,7 @@ App::error()
$publish = $error->isPublishable();
}
if ($logger && $publish) {
if ($logger && ($publish || $error->getCode() === 0)) {
try {
/** @var Utopia\Database\Document $user */
$user = $utopia->getResource('user');

View file

@ -244,17 +244,10 @@ class Exception extends \Exception
{
$this->errors = Config::getParam('errors');
$this->type = $type;
$this->code = $this->errors[$type]['code'] ?? $code;
$this->message = $this->errors[$type]['description'] ?? $message;
$this->publish = !isset($code) ? true : $code >= 500 || $code === 0;
if (isset($this->errors[$type])) {
$this->code = $this->errors[$type]['code'];
$this->message = $this->errors[$type]['description'];
$this->publish = $this->errors[$type]['publish'] ?? true;
}
$this->message = $message ?? $this->message;
$this->code = $code ?? $this->code;
$this->publish = $this->errors[$type]['publish'] ?? ($this->code >= 500);
parent::__construct($this->message, $this->code, $previous);
}