public function addError($error, $key = null)
    {
        if (is_string($error)) {
            $error = new Exception($error);
        } elseif ($error instanceof Exception) {
            // Nothing to do
        } else {
            throw new Exception('only string errors or instances of Exception can be added');
        }

        if ($key) {
            $this->errors[$key] = $error;
        } else {
            $this->errors[] = $error;
        }

        return false;
    }
public function addError($error, $key = null)
    {
        if (is_string($error)) {
            $error = new Exception($error);
        } elseif ($error instanceof Exception) {
            // Nothing to do
        } else {
            throw new Exception('only string errors or instances of Exception can be added');
        }

        if ($key) {
            $this->errors[$key] = $error;
        } else {
            $this->errors[] = $error;
        }

        return false;
    }
public function addError ( $ error , $ key = null ) { if ( is_string ( $ error ) ) { $ error = new Exception ( $ error ) ; } elseif ( $ error instanceof Exception ) { // Nothing to do } else { throw new Exception ( 'only string errors or instances of Exception can be added' ) ; } if ( $ key ) { $ this -> errors [ $ key ] = $ error ; } else { $ this -> errors [ ] = $ error ; } return false ; }
Add error.

If the key is not provided the method will just
add another element to the array.

@param Exception|string $error The error
@param string           $key   The associative array key

@throws Exception

@return bool Always returns false
Add error .