Shows help screen with available commands on demand or on error.

@param string $error The error to show additionally.

@author Benjamin Carl <opensource@clickalicious.de>
498242
protected function showHelp($error = null)
    {
        if ($error !== null) {
            $this->showError($error);
        }

        $message = 'Available commands:';
        echo PHP_EOL.PHP_EOL.$message.PHP_EOL.$this->getFlags()->getDefaults().PHP_EOL;
        exit;
    }
151429
protected function handleError($response) {
    $errorMsg = $response->getValue('errorMsg');
    self::$logger->error("Error in remote call to ".$this->serverUrl.": ".$errorMsg."\n".$response->toString(), __FILE__);
    throw new \RuntimeException("Error in remote call to ".$this->serverUrl.": ".$errorMsg);
  }
39838
protected function help($command = null)
    {
        if ($command && isset(self::$help[$command])) {
            $data = self::$help[$command];
        } else {
            $data = self::$fallbackHelp;
        }

        return $this->render('system/cli/help.phtml', $data);
    }
562788
private function inform_user_of_error($error) {
        global $USER;

        // The message will be sent from the intended user.
        $userfrom = clone $USER;
        $userfrom->customheaders = array();

        if ($messageid = $this->currentmessagedata->messageid) {
            // Adding the In-Reply-To header ensures that it is seen as a reply and threading is maintained.
            $userfrom->customheaders[] = 'In-Reply-To: ' . $messageid;
        }

        $messagedata = new \stdClass();
        $messagedata->subject = $this->currentmessagedata->envelope->subject;
        $messagedata->error = $error;

        $eventdata = new \core\message\message();
        $eventdata->courseid            = SITEID;
        $eventdata->component           = 'tool_messageinbound';
        $eventdata->name                = 'messageprocessingerror';
        $eventdata->userfrom            = $userfrom;
        $eventdata->userto              = $USER;
        $eventdata->subject             = self::get_reply_subject($this->currentmessagedata->envelope->subject);
        $eventdata->fullmessage         = get_string('messageprocessingerror', 'tool_messageinbound', $messagedata);
        $eventdata->fullmessageformat   = FORMAT_PLAIN;
        $eventdata->fullmessagehtml     = get_string('messageprocessingerrorhtml', 'tool_messageinbound', $messagedata);
        $eventdata->smallmessage        = $eventdata->fullmessage;
        $eventdata->notification        = 1;

        if (message_send($eventdata)) {
            mtrace("---> Notification sent to {$USER->email}.");
        } else {
            mtrace("---> Unable to send notification.");
        }
    }
145592
public function error($error)
    {
        $this->process_status = 'error';
        $this->message = '';
        $this->error .= $error;

        return $this;
    }
1173174
public function loginErrorAccessManagement($error)
    {
        // Define default message
        $message = is_bool($error) && $error ? Translate::t('configuration.accessmanagement.login.error') : $error;

        // Change login error message
        add_filter('login_errors', function () use ($message) {
            if (!empty($message)) {
                return $message;
            }
        });
    }
801559
protected function seeError(string $error, int $status = null)
    {
        if (! is_null($status)) {
            $this->seeStatusCode($status);
        }

        if ($this->app->config->get('responder.status_code')) {
            $this->seeJson([
                'status' => $status
            ]);
        }

        return $this->seeJson([
            'success' => false
        ])->seeJsonSubset([
            'error' => [
                'code' => $error
            ]
        ]);
    }
302150
protected function addError($error){

        $this->valid = false;

        if($error instanceof Exception){
            $this->errors[] = array(
                'file' => $error->getFile(),
                'line' => $error->getLine(),
                'message' => "[".get_class($error)."] ".$error->getMessage()
            );
        }elseif($error instanceof LibXMLError){
            $this->errors[] = array(
                'file' => $error->file,
                'line' => $error->line,
                'message' => "[".get_class($error)."] ".$error->message
            );
        }elseif(is_string($error)){
            $this->errors[] = array(
                'message' => $error
            );
        }
    }
278786
public function displayFatal($error)
    {
        $data = array();
        $data['code'] = 0;
        $data['message'] = $error['message'];
        $data['file'] = $error['file'];
        $data['line'] = $error['line'];
        $data['type'] = 'fatal';
        $data = $this->_formatError(debug_backtrace(), $data);

        $this->render('error', $data);
    }
519074
protected static function displayError($errorMessage, $displayHelp = false, $exit = true)
    {
        echo "\n  " . self::red() . 'Error: ' . self::resetColor() . $errorMessage . "\n";
        if ($displayHelp) {
            self::helpAction();
        } else {
            echo "\n";
        }
        if ($exit) {
            exit(1);
        }
    }
653326
public function addError(ErrorInterface $error)
    {
        // create a local copy of the error stack
        $errors = $this->errors;

        // append the error to the stack
        $errors[] = $error;

        // copy the error stack back to the thread context
        $this->errors = $errors;
    }
1209483
public function setErrorType($error)
    {
        if (isset($this->errorTypes[$error])) {
            $this->message = trim($this->errorTypes[$error].': '.$this->message);
        }
    }
446322
public function addError($error)
    {
        $errors = $this->getAttribute('errors') ?: [];

        $errors[] = $error;

        $this->setAttribute('errors', $errors);

        return $this;
    }
228683
public function addError(ErrorStore $error)
    {
        $this->outputMode = self::MODE_ERROR;
        $this->errors[] = $error;
    }
1301703
private function setError($error) {
		
		$this->errors[] = $error;
		$app = Application::getInstance();
		$app->logError($error);
		
	}
1084419
public function addError($error) {
		if ($error instanceof \Exception) {
			$error = $error->getMessage();
		}

		$this->messages['errors'][] = $error;
		$this->saveSession();
	}
1047729
private function setError($error)
    {
        if (strpos($error, 'ERROR') !== false) {
            if (array_key_exists($error, $this->errors)) {
                throw new Exception($this->errors[$error]);
            } else {
                throw new Exception($error);
            }
        }
    }