捕获SOAP的错误?

How to catch an error from a SOAP?

How can I avoid the fatal error and convert it to my own error.. In this example it's a SERVER_BUSY

code

class Validate_vatno {
    private $client = null;

    private $options = array(
        'debug' => false
        );

    public function __construct(){
        $this->client = new SoapClient('http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl', array('trace' => true));
    }

    public function check($country, $vatno){
        $result = $this->client->checkVat(array(
            'countryCode' => $country,
            'vatNumber' => $vatno
            ));

        if(!empty($this->options['debug'])){
            echo '<pre>'.htmlentities($this->client->__getLastResponse()).'</pre>';
        }

        if($result->valid){
            list($denomination, $name) = explode(' ', $result->name, 2);

            return array(
                'denomination' => utf8_decode($denomination),
                'name' => ucwords(utf8_decode($name)),
                'address' => ucwords(utf8_decode($result->address)),
                );
        }
        else{
            return array();
        }
    }
}
$vatValidation = new Validate_vatno();

if($return = $vatValidation->check('DK', 33214944)){
    echo '<h1>valid one!</h1>';
    echo 'denomination: ' . $return['denomination']. '<br/>';
    echo 'name: ' . $return['name']. '<br/>';
    echo 'address: ' . $return['address']. '<br/>';
}
else{
    echo '<h1>Invalid VAT</h1>';
}

error

Fatal error: Uncaught SoapFault exception: [soapenv:Server] { 'SERVER_BUSY' } in /var/www/

Review how to handle exceptions

Throwing and Catching a Exception

<?php
function inverse($x) {
    if (!$x) {
        throw new Exception('Division by zero.');
    }
    else return 1/$x;
}

try {
    echo inverse(5) . "
";
    echo inverse(0) . "
";
} catch (Exception $e) {
    echo 'Caught exception: ',  $e->getMessage(), "
";
}

// Continue execution
echo 'Hello World';
?>