Skip to content

Commit

Permalink
Merge pull request #30 from zfbase/feature-popup-exception
Browse files Browse the repository at this point in the history
Feature popup exception
  • Loading branch information
IlyaSerdyuk authored May 15, 2020
2 parents 5ac41b7 + 73f8bfc commit f49efa8
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions library/ZFE/Controller/AbstractResource/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public function deleteAction($redirectUrl = null)
return true;
}
} catch (Throwable $ex) {
ZFE::popupException($ex);

$this->error('Не удалось удалить ' . mb_strtolower($modelName::$nameSingular), $ex, false !== $redirectUrl);

if (false !== $redirectUrl) {
Expand Down Expand Up @@ -115,6 +117,8 @@ public function undeleteAction($redirectUrl = null)
return true;
}
} catch (Throwable $ex) {
ZFE::popupException($ex);

$this->error('Не удалось восстановить ' . mb_strtolower($modelName::$nameSingular), $ex, false !== $redirectUrl);

if (false !== $redirectUrl) {
Expand Down
2 changes: 2 additions & 0 deletions library/ZFE/Controller/AbstractResource/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public function editAction($redirectUrl = null, array $formOptions = [])
$this->abort(500, 'После сохранения в записи отсутствует ID.');
}
} catch (Throwable $ex) {
ZFE::popupException($ex);

$this->error('Сохранить не удалось', $ex);
}
}
Expand Down
2 changes: 2 additions & 0 deletions library/ZFE/Controller/AbstractResource/History.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ public function restoreAction($redirectUrl = null)

$status = true;
} catch (Throwable $ex) {
ZFE::popupException($ex);

$this->error('Не удалось откатить ' . mb_strtolower($modelName::$nameSingular) . ' к версии ' . $version, $ex);

$status = false;
Expand Down
2 changes: 2 additions & 0 deletions library/ZFE/Controller/AbstractResource/Merge.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ public function mergeHelperAction()

ZFE_Notices::ok($msg);
} catch (Throwable $ex) {
ZFE::popupException($ex);

if ($this->_request->isXmlHttpRequest()) {
$this->_json(self::STATUS_FAIL, [], $ex->getMessage());
}
Expand Down
2 changes: 2 additions & 0 deletions library/ZFE/Controller/Default/History.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public function diffAction()
throw new ZFE_Controller_Exception();
}
} catch (Throwable $ex) {
ZFE::popupException($ex);

$this->abort(500, 'Не корректный класс записи');
}

Expand Down
3 changes: 3 additions & 0 deletions library/ZFE/Tasks/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ final public function manage($tasks, Zend_Log $logger = null): int
try {
$performer = $this->assign($task);
} catch (ZFE_Tasks_Exception $e) {
ZFE::popupException($e);
$this->logHelper($logger, $e->getMessage(), Zend_Log::ERR);
continue;
}
Expand All @@ -249,6 +250,8 @@ final public function manage($tasks, Zend_Log $logger = null): int
$this->logHelper($logger, "Task #{$task->id} performed successfully");
$managed++;
} catch (ZFE_Tasks_Performer_Exception $e) {
ZFE::popupException($e);

$task->errors = $e->getMessage();
$task->save();

Expand Down
11 changes: 11 additions & 0 deletions library/ZFE/Utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,15 @@ public static function makeAbbr(string $text)

return $text;
}

/**
* Пропустить перехват исключения (если в конфигурации разрешено).
*/
public static function popupException(Exception $ex)
{
$config = Zend_Registry::get('config');
if ($config->debug->popupExceptions ?? false) {
throw $ex;
}
}
}

0 comments on commit f49efa8

Please sign in to comment.