protected function processError($output, $exceptionOnError = true, $exceptionClass = ShellException::class)
    {
        if ($exceptionOnError && $this->hadError()) {
            $exceptionClass = $exceptionClass ?: ShellException::class;
            throw new $exceptionClass($output);
        }

        return $this;
    }