Override properties of an exception specific to the INI section
of a CMS object.
@param \Exception $exception The exception to modify.
@return bool
167305
protected function processIni(Exception $exception)
    {
        $message = $exception->getMessage();

        /*
         * Expecting: syntax error, unexpected '!' in Unknown on line 4
         */
        if (!starts_with($message, 'syntax error')) {
            return false;
        }
        if (strpos($message, 'Unknown') === false) {
            return false;
        }
        if (strpos($exception->getFile(), 'Ini.php') === false) {
            return false;
        }

        /*
         * Line number from parse_ini_string() error.
         * The last word should contain the line number.
         */
        $parts = explode(' ', $message);
        $line = array_pop($parts);
        $this->line = (int)$line;

        // Find where the ini settings section begins
        $offsetArray = SectionParser::parseOffset($this->compoundObject->getContent());
        $this->line += $offsetArray['settings'];

        $this->message = $message;

        // Account for line 0
        $this->line--;

        return true;
    }
565083
protected function prepareReplacements(Exception $exception)
    {
        // Retrieve status code of exception
        $statusCode = $this->getStatusCode($exception);

        // Retrieve message of exception
        //
        // If the exception does not have a message,
        // we'll fallback to a message of the status code and status message.
        if (! $message = $exception->getMessage()) {
            // Response::$statusTexts does not contain custom codes - default to empty
            $text = isset(Response::$statusTexts[$statusCode]) ? Response::$statusTexts[$statusCode] : 'No message was set in exception';
            $message = sprintf('%d: %s', $statusCode, $text);
        }

        // Base replacements
        $replacements = [
            ':message' => $message,
            // default status code to 500
            ':code' => $exception->getCode() ?: 500,
        ];

        // If exception contains a message bag of errors
        // we'll add them to the replacements array
        if (($exception instanceof NodesException || $exception instanceof MessageBagErrors) && $exception->hasErrors()) {
            $replacements[':errors'] = $exception->getErrors();
        }

        // If exception contains local message
        if ($exception instanceof NodesException && $exception->getLocaleMessage()){
            $replacements[':locale_message'] = $exception->getLocaleMessage();
        }

        // If we're running in debug mode,
        // we'll add much more detailed information
        // extracted from the exception.
        if ($this->runningInDebugMode()) {
            $replacements[':debug'] = [
                'class' => get_class($exception),
                'file' => $exception->getFile(),
                'line' => $exception->getLine(),
                'trace' => explode("\n", $exception->getTraceAsString()),
            ];
        }

        return array_merge($replacements, $this->replacements);
    }
474003
protected function processPhp(Exception $exception)
    {
        /*
         * Fatal Error
         */
        if ($exception instanceof \Symfony\Component\Debug\Exception\FatalErrorException) {
            $check = false;

            // Expected: */modules/cms/classes/CodeParser.php(165) : eval()'d code line 7
            if (strpos($exception->getFile(), 'CodeParser.php')) {
                $check = true;
            }

            // Expected: */storage/cms/cache/39/05/home.htm.php
            if (strpos($exception->getFile(), $this->compoundObject->getFileName() . '.php')) {
                $check = true;
            }

            if (!$check) {
                return false;
            }
        /*
         * Errors occurring the PHP code base class (Cms\Classes\CodeBase)
         */
        }
        else {
            $trace = $exception->getTrace();
            if (isset($trace[1]['class'])) {
                $class = $trace[1]['class'];
                if (!is_subclass_of($class, CodeBase::class)) {
                    return false;
                }
            }
        }

        $this->message = $exception->getMessage();

        // Offset the php, namespace and bracket tags from the generated class.
        $this->line = $exception->getLine() - 3;

        // Find where the php code section begins
        $offsetArray = SectionParser::parseOffset($this->compoundObject->getContent());
        $this->line += $offsetArray['code'];

        // Account for line 0
        $this->line--;

        return true;
    }
567699
protected function getTransformed(Exception $exception)
    {
        foreach ($this->make((array) $this->getConfigItem('transformers')) as $transformer) {
            $exception = $transformer->transform($exception);
        }

        return $exception;
    }
522566
protected function handleException($exception) : void
    {
        $previous = $exception->getPrevious();

        if ($exception instanceof QueryException) {
            throw new $exception($exception->getMessage(), $exception->getBindings(), $previous);
        }

        throw new $exception($exception->getMessage(), $previous);
    }
88176
public function fromException( Exception $exception )
    {
        $response = new HttpResponse();
        $response->setStatusCode( 200 );
        $response->headers->set( 'Content-Type', 'text/xml' );
        $response->setContent( $this->generateXmlFromException( $exception ) );
        return $response;
    }
578262
private function processException(Exception $exception)
    {
        $context = [
            'exception_class' => get_class($exception),
        ];

        return $this->addStackContext($exception, $context);
    }
191799
protected function prepareReplacements(Exception $exception)
    {
        $statusCode = $this->getStatusCode($exception);

        if (! $message = $exception->getMessage()) {
            $message = \sprintf('%d %s', $statusCode, Response::$statusTexts[$statusCode]);
        }

        $replacements = [
            ':message' => $message,
            ':status_code' => $statusCode,
        ];

        if ($exception instanceof MessageBagErrors && $exception->hasErrors()) {
            $replacements[':errors'] = $exception->getErrors();
        }

        if ($exception instanceof ValidationException) {
            $replacements[':errors'] = $exception->errors();
            $replacements[':status_code'] = $exception->status;
        }

        if ($code = $exception->getCode()) {
            $replacements[':code'] = $code;
        }

        if ($this->runningInDebugMode()) {
            $replacements[':debug'] = [
                'line' => $exception->getLine(),
                'file' => $exception->getFile(),
                'class' => \get_class($exception),
                'trace' => \explode("\n", $exception->getTraceAsString()),
            ];

            // Attach trace of previous exception, if exists
            if (! \is_null($exception->getPrevious())) {
                $currentTrace = $replacements[':debug']['trace'];

                $replacements[':debug']['trace'] = [
                    'previous' => \explode("\n", $exception->getPrevious()->getTraceAsString()),
                    'current' => $currentTrace,
                ];
            }
        }

        return \array_merge($replacements, $this->replacements);
    }
336011
final public static function getBaseException(\Exception $exception)
    {
        while ($exception->getPrevious() !== null) {
            $exception = $exception->getPrevious();
        }

        return $exception;
    }
945704
public function addException(\Exception $exception)
    {
        if (!$exception instanceof Exception) {
            @trigger_error('Clients may only throw exceptions of type '.Exception::class.'. Setting an exception of class '.get_class($exception).' will not be possible anymore in the future', E_USER_DEPRECATED);
        }
        $this->exceptions[] = $exception;
    }
340047
protected function _throwException($exception = null)
    {
        if ($exception !== null) {
            if (!Configure::read('debug') && $exception instanceof SecurityException) {
                $exception->setReason($exception->getMessage());
                $exception->setMessage(self::DEFAULT_EXCEPTION_MESSAGE);
            }
            throw $exception;
        }
        throw new BadRequestException(self::DEFAULT_EXCEPTION_MESSAGE);
    }
506578
protected function errorResponse(\Exception $exception)
    {
        $error = $this->config->get('datatables.error');
        $debug = $this->config->get('app.debug');

        if ($error === 'throw' || (! $error && ! $debug)) {
            throw new Exception($exception->getMessage(), $code = 0, $exception);
        }

        $this->getLogger()->error($exception);

        return new JsonResponse([
            'draw'            => (int) $this->request->input('draw'),
            'recordsTotal'    => $this->totalRecords,
            'recordsFiltered' => 0,
            'data'            => [],
            'error'           => $error ? __($error) : "Exception Message:\n\n".$exception->getMessage(),
        ]);
    }
910927
public function setException(\Exception $exception = null)
    {
        $this->exception = $exception;
        $this->result = self::FAILED;
    }
816194
public static function exception( $exception ) 
	{
		// clean the main output buffer
		while ( ob_get_level() > 0 ) 
		{
			ob_end_clean();
		}
		
		$error_handler = "\\".CCCORE_NAMESPACE."\\CCError_Handler".( ClanCats::is_cli() ? '_Cli' : '' );
		$error_inspector = "\\".CCCORE_NAMESPACE."\\CCError_Inspector";
		
		if ( is_object( ClanCats::$config ) && ClanCats::$config instanceof CCConfig ) 
		{
			$error_handler = ClanCats::$config->get( 'error.'.( ClanCats::is_cli() ? 'cli_' : '' ).'handler', $error_handler );
			$error_inspector = ClanCats::$config->get( 'error.inspector', $error_inspector );
		}
		
		$inspector = new $error_inspector( $exception );
		
		$handler = new $error_handler( $inspector );
		
		$handler->handle();
	}
584665
public function exceptionHandler($exception) {
		try {
			// load errorhandler
			$debug = Factory::load('Debug');
			$debug->errorhandler($exception);
		} catch (\Exception $e) {
			echo "<pre>$exception</pre>\n\n";

			// useful if the \Exception handler itself contains errors
			echo "<pre>The Debug class threw an exception:\n$e</pre>";
		}
	}
431779
public function handlerVerbose(\Exception $exception)
    {
        if (!headers_sent()) {
            header('HTTP/1.1 500 Internal Server Error', true, 500);
            header('Content-type: text/html; charset=UTF-8');
        }

        echo sprintf(
            '<!DOCTYPE html>
        <html>
        <head>
            <title>Bad Moss: %1$s - %2$s - %3$s:%4$u</title>
            <style>
                body, code { font: medium/1.5em monospace; }

                div:nth-child(4) { position: fixed; right: 0.5em; top: 0.5em; width: 100%; padding: 0.25em 1em; }
                div:nth-child(4) a { text-decoration: none; padding: 0.25em 0.75em; color: #ffe; background: #8c3; border-radius: 1em; }

                table { width: auto; border-collapse: collapse; overflow: hidden; }

                td { vertical-align: top; }
                td:nth-child(1) { position: relative; width: 3em; padding: 0 0.5em 0 0; text-align: right; color: #999; border-right: 1px solid #999; z-index: 1; }
                td:nth-child(2) { position: relative; padding: 0 0 0 0.5em; z-index: 2; }

                td, td span { white-space: nowrap; }
                td span#mark { position: relative; font-weight: bold; color: #f00; }
                td span#mark:after { content: \'.\'; position: absolute; top: -0.2em; left: -2em; width: 10000em; background: #f00; opacity: 0.25; }
            </style>
        </head>
        <body>
            <h1>Bad Moss: %1$s - &quot;%2$s&quot;</h1>

                <div>
                    <h2 id="trace">Trace</h2>
                    %6$s
                </div>
                <div>
                    <h2 id="listing">File: %3$s:%4$u</h2>
                    %5$s
                </div>
                <div>
                    <a href="#trace">Trace</a>
                    <a href="#listing">Listing</a>
                    <a href="#mark">Error line</a>
                </div>
        </body>
        </html>',
            get_class($exception),
            $exception->getMessage(),
            $exception->getFile(),
            $exception->getLine(),
            $this->lineNumbers('<br />', highlight_file($exception->getFile(), true), $exception->getLine()),
            $this->prettyCode($exception->getTrace())
        );
    }
365762
protected function getErrorType(\Exception $exception)
    {
        $errorType = get_class($exception);

        $pos = strrpos($errorType, '\\');
        if ($pos !== false) {
            $errorType = substr($errorType, $pos);
        }

        $errorType = Str::replaceLast($errorType, 'Exception', '');

        if (!$errorType) {
            $errorType = 'Unknown';
        }

        return $errorType;
    }