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
+7 -4
View File
@@ -1,5 +1,8 @@
<?php
/**
use xPaw\SourceQuery\Exception\InvalidPacketException;
use xPaw\SourceQuery\Exception\SocketException;
/**
* Class written by xPaw
*
* Website: http://xpaw.me
@@ -48,7 +51,7 @@
if( $ErrNo || $this->Socket === false )
{
throw new Exception( 'Could not create socket: ' . $ErrStr );
throw new SocketException( 'Could not create socket: ' . $ErrStr, SocketException::COULD_NOT_CREATE_SOCKET);
}
Stream_Set_Timeout( $this->Socket, $Timeout );
@@ -143,7 +146,7 @@
if( CRC32( $Buffer ) !== $PacketChecksum )
{
throw new SourceQueryException( 'CRC32 checksum mismatch of uncompressed packet data.' );
throw new InvalidPacketException( 'CRC32 checksum mismatch of uncompressed packet data.', InvalidPacketException::CHECKSUM_MISMATCH);
}
}
@@ -151,7 +154,7 @@
}
else
{
throw new SourceQueryException( 'Socket read: Raw packet header mismatch. (0x' . DecHex( $Header ) . ')' );
throw new InvalidPacketException( 'Socket read: Raw packet header mismatch. (0x' . DecHex( $Header ) . ')', InvalidPacketException::PACKET_HEADER_MISMATCH);
}
}