Some checks are pending
Module sub-split / Sub-split (push) Waiting to run
- Base: wintercms/winter branch 1.2 (full framework) - Theme vivespos: Canvas 7 + Bootstrap 5 CDN, custom CSS - Layout: deferred GTM/GA4 tracking, JSON-LD SoftwareApplication - Partials: hero (offline-first), features, modes (offline/nube toggle), screenshots, pricing (3 planes), comparison, FAQ, CTA - Plugin VivesPOS.Site with ContactForm - Dockerfile: PHP 8.2 Apache, port 80, healthcheck - Added winter/wn-pages, blog, sitemap, seo plugins - Active theme set to vivespos
55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php namespace Backend\Traits;
|
|
|
|
use Exception;
|
|
use System\Classes\ErrorHandler;
|
|
use System\Models\EventLog;
|
|
use Winter\Storm\Exception\ApplicationException;
|
|
|
|
/**
|
|
* Error Maker Trait
|
|
* Adds exception based methods to a class, goes well with `System\Traits\ViewMaker`.
|
|
*
|
|
* @package winter\wn-backend-module
|
|
* @author Alexey Bobkov, Samuel Georges
|
|
*/
|
|
trait ErrorMaker
|
|
{
|
|
/**
|
|
* @var string Object used for storing a fatal error.
|
|
*/
|
|
protected $fatalError;
|
|
|
|
/**
|
|
* @return boolean Whether a fatal error has been set or not.
|
|
*/
|
|
public function hasFatalError()
|
|
{
|
|
return !is_null($this->fatalError);
|
|
}
|
|
|
|
/**
|
|
* @return string The fatal error message
|
|
*/
|
|
public function getFatalError()
|
|
{
|
|
return $this->fatalError;
|
|
}
|
|
|
|
/**
|
|
* Sets standard page variables in the case of a controller error.
|
|
*/
|
|
public function handleError($exception)
|
|
{
|
|
if (
|
|
$exception instanceof Exception
|
|
&& !($exception instanceof ApplicationException)
|
|
) {
|
|
EventLog::addException($exception);
|
|
}
|
|
|
|
$errorMessage = ErrorHandler::getDetailedMessage($exception);
|
|
$this->fatalError = $errorMessage;
|
|
$this->vars['fatalError'] = $errorMessage;
|
|
}
|
|
}
|