Throw exception on session initialization error

This commit is contained in:
alphayax 2016-05-18 20:15:03 +02:00
parent 8cff7f8a6f
commit a6a4e20ca0
2 changed files with 8 additions and 5 deletions

View File

@ -29,12 +29,12 @@ class FileSystemListing extends Service {
'removeHidden' => $removeHidden, 'removeHidden' => $removeHidden,
]); ]);
$FsTask_xs = $rest->getCurlResponse()['result']; $FileInfo_xs = $rest->getCurlResponse()['result'];
$FsTasks = []; $FileInfos = [];
foreach( $FsTask_xs as $fsTask_x) { foreach( $FileInfo_xs as $FileInfo_x) {
$FsTasks[] = new FileInfo( $fsTask_x); $FileInfos[] = new FileInfo( $FileInfo_x);
} }
return $FsTasks; return $FileInfos;
} }
/** /**

View File

@ -48,6 +48,9 @@ class Session extends Service {
'password' => hash_hmac( 'sha1', $this->challenge, $this->application->getAppToken()), 'password' => hash_hmac( 'sha1', $this->challenge, $this->application->getAppToken()),
]); ]);
if( ! $rest->getCurlResponse()['success']){
throw new \Exception( $rest->getCurlResponse()['error_code'] .' : '. $rest->getCurlResponse()['msg']);
}
$this->session_token = $rest->getCurlResponse()['result']['session_token']; $this->session_token = $rest->getCurlResponse()['result']['session_token'];
} }