public function onFatalError($callback, $clearOutput = false)
    {
        if (!$clearOutput) {
            $this->onFatalError = $callback;
        } else {
            $this->onFatalError = function ($error) use ($callback) {
                $this->clearOutputBuffer();
                $callback($error);
            };
        }
    }