Ignore:
Timestamp:
04/27/12 15:18:00 (12 years ago)
Author:
niltonneto
Message:

Ticket #2507 - Modificada implementação para tratamento de erros por Exception.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/webservice/api/rest/core/Expresso.php

    r6022 r6061  
    5959        } 
    6060         
    61         public function setError($errorID, $arg1 = false) { 
    62                 if($errorID) 
    63                         $this-> error = Errors::get($errorID, $arg1); 
    64                 else 
    65                         $this-> error = null; 
     61        public function setError($error) { 
     62                $this-> error = $error; 
    6663        } 
    6764         
     
    9693                $response->addHeader('content-type', 'application/json'); 
    9794 
     95                if($this->getId()) 
     96                        $body['id']     = $this->getId(); 
     97                if($this->getResult()) 
     98                        $body['result'] = $this->getResult(); 
     99                else 
     100                        throw new ResponseException("",Errors::E_UNKNOWN_ERROR); 
    98101                 
    99                 if($this->getResult()) { 
    100                         $body['result'] = $this->getResult(); 
    101                 } 
    102                 elseif($this->getError()){ 
    103                         $body['error'] = $this->getError(); 
    104                 } 
    105                 else{ 
    106                         $this->setError(Errors::E_INTERNAL_ERROR); 
    107                         $body['error'] = $this->getError(); 
    108                 } 
    109                  
    110                 if($this->getId()) { 
    111                         $body['id']     = $this->getId(); 
    112                 } 
    113  
    114102                $response->body = json_encode($body); 
    115103                 
     
    143131                        list($sessionid, $kp3) = explode(":", $this->getParam('auth')); 
    144132                        if($GLOBALS['phpgw']->session->verify($sessionid, $kp3)){                                                                        
    145                                 return true; 
     133                                return $sessionid; 
    146134                        } 
    147135                        else{ 
    148                                 $this-> setError(Errors::LOGIN_AUTH_INVALID); 
    149                                 return false; 
     136                                throw new ResponseException("",Errors::LOGIN_AUTH_INVALID); 
    150137                        } 
    151138                } 
    152139                else{ 
    153                         $this-> setError(Errors::LOGIN_NOT_LOGGED_IN); 
    154                         return false; 
     140                        throw new ResponseException("",Errors::LOGIN_NOT_LOGGED_IN); 
    155141                }                
    156142        }        
Note: See TracChangeset for help on using the changeset viewer.