public function formatStacktrace(array $trace, $stripFilepath = '', $trimPath = '')
    {
        $out = '';
        foreach ($trace as $index => $row) {

            if ($stripFilepath && isset($row['file']) && strpos($row['file'], $stripFilepath) !== false) {
                continue;
            }

            if ($trimPath && isset($row['file'])) {
                $row['file'] = str_replace($trimPath, '', $row['file']);
            }

            if (isset($row['file'])) {
                $out .= "[$index] {$row['file']}:{$row['line']}\n";
            } else {
                // sometimes there is undefined index 'file'
                $out .= "[$index] (?) {$row['class']}:{$row['function']}\n";
            }

        }

        return $out;
    }