/**
* Get the most recent error message.
*
* @param integer $i Option error index.
* @param boolean $toString Indicates if Exception objects should return their error message.
*
* @return string Error message
*
* @since 1.7.0
* @deprecated 3.1.4 JError has been deprecated
*/
public function getError($i = null, $toString = true)
{
// Find the error
if ($i === null) {
// Default, return the last message
$error = end($this->_errors);
} elseif (!\array_key_exists($i, $this->_errors)) {
// If $i has been specified but does not exist, return false
return false;
} else {
$error = $this->_errors[$i];
}
// Check if only the string is requested
if ($error instanceof \Exception && $toString) {
return $error->getMessage();
}
return $error;
}