Get backtrace from where error was raised as string as per built-in Exception class
@return string
333624
public function getTraceAsString() {
		$lines = array ();
		for( $i = 0; $i < count($this->trace); $i++ ){
			$a = $this->trace[$i];
			$call = "{$a['function']}()";
			if( isset($a['class']) ){
				$call = "{$a['class']}{$a['type']}$call";
			}
			$lines[] = "#$i {$a['file']}({$a['line']}): $call";
		} 
		$lines[] = "#$i {main}";
		return implode( "\n", $lines );
	}
1100408
public function toString()
    {
        $errorString = '';
        foreach ((array)$this->errors as $err) {
            $errorString .= $err->getDefaultErrorMessage().", ";
        }
        return substr($errorString, 0, -2);
    }
783557
protected function getBacktrace()
    {
        // Remove the fist step from the backtrace,
        // because that is the internal function in kreXX.
        $backtrace = debug_backtrace();

        // We remove all steps that came from inside the kreXX lib.
        $krexxScr = KREXX_DIR . 'src';
        foreach ($backtrace as $key => $step) {
            if (isset($step[static::TRACE_FILE]) && strpos($step[static::TRACE_FILE], $krexxScr) !== false) {
                unset($backtrace[$key]);
            } else {
                // No need to ga wurther, because we should have passed the
                // kreXX part.
                break;
            }
        }

        // Reset the array keys, because the 0 is now missing.
        return array_values($backtrace);
    }
221129
protected function getBacktrace(\Exception $exception)
    {
        $backtrace = array();

        $backtrace[] = '---';
        $backtrace[] = $this->getErrorMessage($exception);
        $backtrace[] = '---';

        // Allow marshalling of the trace: PHP marks getTraceAsString as final :-(
        if (method_exists($exception, 'getPreviousTraceAsString')) {
            $backtrace = array_merge($backtrace, explode("\n", $exception->getPreviousTraceAsString()));
        } else {
            $backtrace = array_merge($backtrace, explode("\n", $exception->getTraceAsString()));
        }

        if (($previous = $exception->getPrevious())) {
            $backtrace = array_merge($backtrace, $this->getBacktrace($previous)); // Recurse
        }

        return $backtrace;
    }
642282
static private function getTextBackTrace($backtrace) {
		$str = '';
	
		foreach ($backtrace as $step) {
			if ($step['function']!='getTextBackTrace' && $step['function']!='handle_error')
			{
				if (isset($step['file']) && isset($step['line'])) {
					$str .= "In ".$step['file'] . " at line ".$step['line'].": ";
				}
				if (isset($step['class']) && isset($step['type']) && isset($step['function'])) {
					$str .= $step['class'].$step['type'].$step['function'].'(';
				}
	
				if (is_array($step['args'])) {
					$drawn = false;
					$params = '';
					foreach ( $step['args'] as $param)
					{
						$params .= self::getPhpVariableAsText($param);
						//$params .= var_export($param, true);
						$params .= ', ';
						$drawn = true;
					}
					$str .= $params;
					if ($drawn == true)
					$str = substr($str, 0, strlen($str)-2);
				}
				$str .= ')';
				$str .= "\n";
			}
		}
	
		return $str;
	}
966178
public function getFirstError(): string
    {
        $result = '';
        $errors = $this->getErrors();
        $firstField = reset($errors);

        if ($firstField && isset($firstField[0])) {
            $result = $firstField[0];
        }

        return $result;
    }
939464
public function getBetterTrace() {
        $betterTrace = $this->betterTrace;

        if (!$betterTrace) {
            // transform the original stacktrace into a better one
            $betterTrace = DebugHelper::fixTrace($this->getTrace(), $this->getFile(), $this->getLine());

            /*
            // if the exception was thrown in a magic "__set()" shift frames until we reach the erroneous assignment
            while (strtolower($trace[0]['function']) == '__set') {
                \array_shift($trace);
            }

            // if the exception was thrown in a magic "__call()" shift frames until we reach the erroneous call
            if (strtolower($trace[0]['function']) == '__call') {
                while (strtolower($trace[0]['function']) == '__call') {
                    \array_shift($trace);
                }
                \array_shift($trace);                              // that's one level more than for "__set()"
            }
            */

            // store the new stacktrace
            $this->betterTrace = $betterTrace;
        }
        return $betterTrace;
    }
398295
public function getShortError()
	{
		$error	= array_shift( explode( "\n", trim( $this->error ) ) );
		$error	= preg_replace( "@^Parse error: (.*) in (.*) on (.*)$@i", "\\1 on \\3", $error );
		return $error;
	}
558054
public function getFirstError()
    {
        if (empty($this->errorMessages)) {
            return '';
        }

        reset($this->errorMessages);
        return current(current($this->errorMessages));
    }
665206
protected function getCallerFromStackTrace()
    {
        $trace = collect(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))->forget(0);

        return $trace->first(function ($frame) {
            if (! isset($frame['file'])) {
                return false;
            }

            return ! Str::contains($frame['file'],
                base_path('vendor'.DIRECTORY_SEPARATOR.$this->ignoredVendorPath())
            );
        });
    }
777012
public function getErrorReport()
    {
        if (empty($this->errors)) {
            return '';
        }
        $r = "Some arguments did not pass validation:\n";
        foreach ($this->errors as $letter => $arr) {
            $r .= "  $letter : " . implode(', ', $arr) . "\n";
        }
        $r .= "\n";

        return $r;
    }
1229519
public function getErrorCodeFromHandle()
    {
        $errorNumber = null;

        if ($this->handle !== null) {
            $errorNumber = curl_errno($this->handle);
        }

        return $errorNumber === 0 ? null : $errorNumber;
    }
114312
protected function getExceptionTrace(array $context)
    {
        if (array_key_exists('exception', $context)) {
            if ($context['exception'] instanceof \Exception) {
                $strException = $context['exception']->getTraceAsString();

                return $strException;
            }
        }

        return '';
    }
1127684
final public function getErrorString()
    {

        $errors = self::getErrors();
        $string = '<ul>';
        foreach ($errors as $error) {
            $string .= '<li>' . $error . '</li>';
        }

        //An ordered lists of all errors;
        return $string . '</ul>';
    }
1261677
protected static function _getCallingMethod()
    {
        $_backTrace = debug_backtrace();

        $_thisClass = get_called_class();
        $_type = $_class = $_method = null;

        for ( $_i = 0, $_size = sizeof( $_backTrace ); $_i < $_size; $_i++ )
        {
            if ( isset( $_backTrace[$_i]['class'] ) )
            {
                $_class = $_backTrace[$_i]['class'];
            }

            if ( $_class == $_thisClass )
            {
                continue;
            }

            if ( isset( $_backTrace[$_i]['method'] ) )
            {
                $_method = $_backTrace[$_i]['method'];
            }
            else if ( isset( $_backTrace[$_i]['function'] ) )
            {
                $_method = $_backTrace[$_i]['function'];
            }
            else
            {
                $_method = 'Unknown';
            }

            $_type = $_backTrace[$_i]['type'];
            break;
        }

        if ( $_i >= 0 )
        {
            return str_ireplace( 'Kisma\\Core\\', 'Core\\', $_class ) . $_type . $_method;
        }

        return 'Unknown';
    }
1182080
public function getTraceAsString()
    {
        $remove = "Stack trace:\n";
        $len = strpos($this->_toString, $remove);
        if ($len === false) {
            return '';
        }
        return substr($this->_toString, $len + strlen($remove));
    }
904557
public function getErrorDescription(): string
    {
        if (isset(self::$errorReasons[$this->statusCode][$this->errorReason])) {
            return self::$errorReasons[$this->statusCode][$this->errorReason];
        }

        return '';
    }