Development

Changeset 12748

You must first sign up to be able to contribute.

Changeset 12748

Show
Ignore:
Timestamp:
11/08/08 08:42:43 (5 years ago)
Author:
davec
Message:

Updated error/exception handeling

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfUPSShippingPlugin/README

    r12745 r12748  
    55of costs for all possible shipping types. 
    66 
    7 See test/sfUPSShippingTest.php for examples on useage of the API. 
     7See <a href="http://svn.symfony-project.com/plugins/sfUPSShippingPlugin/test/sfUPSShippingTest.php">test/sfUPSShippingTest.php</a> for examples on useage of the API. 
  • plugins/sfUPSShippingPlugin/lib/sfUPSShipping.class.php

    r12745 r12748  
    4949        ); 
    5050 
     51  public $debugOn = false; 
     52 
    5153      private $apiurl = "https://www.ups.com/ups.app/xml/Rate"; 
    5254 
     
    7779      $isResidentialAddressFlag, $pickupType, 'Rate'); 
    7880 
     81    if( $this->debugOn ) { 
     82      print "Options are : " . print_r($parsed, true) . "\n"; 
     83    } 
     84 
    7985    $price = $parsed->RatedShipment->TotalCharges->MonetaryValue; 
    8086    return($price); 
     
    8793        $isResidentialAddressFlag, '01', 'Shop'); 
    8894 
    89     #print "Options are : " . print_r($parsed, true) . "\n"; 
     95    if( $this->debugOn ) { 
     96      print "Options are : " . print_r($parsed, true) . "\n"; 
     97    } 
    9098 
    9199    $ret = array(); 
     
    176184               </RatingServiceSelectionRequest>"; 
    177185 
    178   #print "Query: $data\n\n"; 
     186  if( $this->debugOn ) { 
     187    print "Query: $data\n\n"; 
     188  } 
    179189   
    180190 
     
    192202 
    193203     
    194     throw(new UPSAPIException("Unknown service code string '$serviceString'")); 
     204    throw(new UPSShippingException("Unknown service code string '$serviceString'")); 
    195205  } 
    196206 
     
    200210    } 
    201211 
    202     throw(new UPSAPIException("Invalid ups code '$code'")); 
     212    throw(new UPSShippingException("Invalid ups code '$code'")); 
    203213  } 
    204214 
     
    223233                $parsedresponse = simplexml_load_string($response, "SimpleXMLElement", LIBXML_NOWARNING ); 
    224234 
     235    if( $parsedresponse->Response->ResponseStatusCode == 0 ) {//Failure 
     236      $description = (string) $parsedresponse->Response->ResponseStatusDescription; 
     237      $severity = (string) $parsedresponse->Response->Error->ErrorSeverity; 
     238      $errorCode= (string) $parsedresponse->Response->Error->ErrorCode; 
     239      $errorDescription = (string) $parsedresponse->Response->Error->ErrorDescription; 
     240      $errorLocation= (string) $parsedresponse->Response->Error->ErrorLocation->ErrorLocationElementName; 
     241 
     242 
     243      throw(new UPSShippingException("Error from UPS server: '$description', '$errorCode', '$errorDescription', '$errorLocation'")); 
     244    } 
     245 
    225246                return $parsedresponse; 
    226247        } 
  • plugins/sfUPSShippingPlugin/test/sfUPSShippingTest.php

    r12745 r12748  
    1616 
    1717$ups = new UPSShipping($accessKey, $userId, $password, $shipperPostalCode, $shipperCountry, $upsAccountNumber); 
     18$ups->debugOn = true; 
    1819 
    1920