protected function writeError(OutputInterface $output, $error)
    {
        $result = [trim($error->getMessage())];

        // If the output is verbose, add file and location
        if ($output->isVerbose()) {
            $file = $error->getFile();
            if ($file) {
                $result[] = "File: {$file}" . ($error->getLine() ? ':' . $error->getLine() : '');
            }
        }

        // If the output is very verbose, add stacktrace
        if ($output->isVeryVerbose()) {
            $trace = $error->getTraceAsString();
            $result[] = 'Trace:';
            $result[] = $trace;
        }

        $this->output->error($result);
    }