Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
namespace saasty\View;
* A very basic view which may contain other elements that are likely to throw exception during render. In which case,
* the exception will be contained within the view and won't break any of the other UI.
class Volatile extends \atk4\ui\View
public $fx = null;
function set($cb = null, $arg2 = null) {
$this->fx = $cb;
return $this;
function recursiveRender() {
try {
} catch(\Throwable $e) {
//$v = $this->add(['Message', 'We have a problem', 'error']);
if ($e instanceof \atk4\core\Exception) {
$msg = $e->getMessage();
$content = $e->getHTML();
} elseif ($e instanceof \Error) {
$msg = get_class($e).': '.$e->getMessage().' (in '.$e->getFile().':'.$e->getLine().')';
$content = nl2br($e->getTraceAsString());
} else {
$msg = get_class($e).': '.$e->getMessage();
$content = null;
if ($this->fx) {
$v = $this->add('View');
call_user_func($this->fx, $v, $msg, $content);
$this->template->appendHTML('Content', $v->getHTML());
$this->app->html->template->appendHTML('HEAD', $v->getJS());
} else {
$this->template->appendHTML('Content', $content);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.