2014-05-09 2 views
0

Google을 통해 스택 오버플로를 조사하고 있습니다.PHP에서 throw 된 COM 예외를 catch 할 수 없습니다.

예외 com_exception을 잡을 수없는 것 같습니까?

public function get($pc){ 
    try{ 
     $this->com = new \COM ("WbemScripting.SWbemLocator"); 
     $WbemServices = $this->com->ConnectServer($pc, $this->com_path, $this->username, $this->password); 
    } catch(com_exception $e){ 
     return false; 
    } 

    $WbemServices->Security_->ImpersonationLevel = 3; 

    $disks = $WbemServices->ExecQuery("Select * from Win32_LogicalDisk"); 

    return $this->format_disk($disks); //Returns disk data in a nice format 
} 

$this->com은 개인 변수입니다. 나는 현재 내 네트워크에서 서버 PC의 디스크 공간을 검색하는 기능을 사용하고 있으며 훌륭하게 작동하지만 입력 된 PC가 네트워크에 존재하지 않으면 예외가 발생합니다.

com_exception 
<b>Source:</b> SWbemLocator<br/><b>Description:</b> The RPC server is unavailable. 

어떤 도움이 크게 감사합니다 :

는 상관없이 내가 뭘, 난 항상 아차 함께 화면받지 않습니다! 더 자세한 정보가 필요하면 알려주십시오.

catch(\com_exception $e){

대신 :

catch(com_exception $e){

이 내 문제를 해결 당신은 PHP에서 네임 스페이스 클래스에 당신이 그 (것)들을 등록 할 수 있도록 예외를 백 슬래시해야 할 때

답변

0

는 것 같아요.

관련 문제