1
0
mirror of https://github.com/xPaw/PHP-Source-Query.git synced 2026-05-18 14:33:34 +02:00

Proposal for better Exceptions

This commit is contained in:
Michael Yoo
2015-02-01 15:13:12 +10:30
parent 6d3355f01f
commit cfcd43111c
6 changed files with 94 additions and 40 deletions
+13 -4
View File
@@ -5,6 +5,8 @@
* Website: http://xpaw.me
* GitHub: https://github.com/xPaw/PHP-Source-Query-Class
*/
use xPaw\SourceQuery\Exception\AuthenticationException;
class SourceQueryGoldSourceRcon
{
@@ -51,7 +53,11 @@
return $Length === FWrite( $this->Socket->Socket, $Command, $Length );
}
/**
* @param int $Length
* @throws AuthenticationException
*/
public function Read( $Length = 1400 )
{
// GoldSource RCON has same structure as Query
@@ -65,10 +71,13 @@
$Buffer = $this->Buffer->Get( );
$Trimmed = Trim( $Buffer );
if( $Trimmed === 'Bad rcon_password.'
|| $Trimmed === 'You have been banned from this server.' )
if($Trimmed === 'Bad rcon_password.')
{
throw new SourceQueryException( $Trimmed );
throw new AuthenticationException($Trimmed, AuthenticationException::BAD_PASSWORD);
}
else if($Trimmed === 'You have been banned from this server.')
{
throw new AuthenticationException($Trimmed, AuthenticationException::BANNED);
}
$ReadMore = false;