Sto cercando di gestire curl quando avvengono degli errori.

Codice PHP:
public function getTokens(){ //functions to get tokens from Ubuntu One using curl
        
        
$app_name_e rawurlencode($this->app_name);
                
        
$curl curl_init($this->login_api_url.$app_name_e);
        
        
curl_setopt($curlCURLOPT_USERPWD$this->user_email.':'.$this->user_pwd);
        
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,FALSE);
        
curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,2);
        
curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
        
        if(!
$response curl_exec($curl)){
            
            echo 
'Curl error: ' curl_error($curl);
            
            
curl_close($curl);
            
            return 
false;
            
            }else{    
                
                
curl_close($curl);
                
                
$response_d json_decode($response);
        
                
$this->conskey $response_d->consumer_key//set consumer key
                
$this->conssec $response_d->consumer_secret//set consumer secret
                
$this->token $response_d->token//set token
                
$this->token_secret $response_d->token_secret//set token secret
        
                
$this->app_name $response_d->name//set app name
        
                
$this->response_d $response_d//to delete
        
                
}
        
        } 
In caso di errore dovrebbe essere stampato echo 'Curl error: ' . curl_error($curl);

Però se per esempio utilizzo un valore sbagliato nel fare la richiesta mi vengono errori relativi alle linee dopo l'else che in questo caso non dovrebbero essere eseguite

Mi viene il dubbio quindi che in caso utilizzi un valore sbagliato curl non trovi nessun errore eppure il risultato dell'esecuzione è un valore vuoto che mi dimostra che curl non sia andato a buon fine