protected function writeException($exception)
    {
        $this->writeNewLine();

        do {
            $exceptionStack[] = $exception;
        } while ($exception = $exception->getPreviousWrapped());

        // Parse nested exception trace line by line.
        foreach (explode("\n", $exception = array_shift($exceptionStack)) as $line) {
            // Print exception name and message.
            if ($exception && false !== $pos = strpos($line, $exception->getClassName() . ': ')) {
                $whitespace = str_repeat(' ', ($pos += strlen($exception->getClassName())) + 2);
                $this->writeWithColor('bg-red,fg-white', $whitespace);

                // Exception name.
                $this->writeWithColor('bg-red,fg-white', sprintf(' %s ', substr($line, 0, $pos)), false);
                // Exception message.
                $this->writeWithColor('fg-red', substr($line, $pos + 1));

                $this->writeWithColor('bg-red,fg-white', $whitespace);

                $exception = array_shift($exceptionStack);

                continue;
            }

            $this->writeWithColor('fg-red', $line);
        }
    }