Block: add the current class to the exception messages for block runtime data serialization

This commit is contained in:
Dylan K. Taylor 2022-07-13 19:50:35 +01:00
parent 8b2d941502
commit 20cb67461f
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -47,6 +47,7 @@ use pocketmine\world\format\Chunk;
use pocketmine\world\Position;
use pocketmine\world\World;
use function count;
use function get_class;
use const PHP_INT_MAX;
class Block{
@ -109,7 +110,7 @@ class Block{
$this->decodeType($reader);
$readBits = $reader->getOffset();
if($typeBits !== $readBits){
throw new \LogicException("Exactly $typeBits bits of type data were provided, but $readBits were read");
throw new \LogicException(get_class($this) . ": Exactly $typeBits bits of type data were provided, but $readBits were read");
}
}
@ -126,7 +127,7 @@ class Block{
$this->decodeState($reader);
$readBits = $reader->getOffset() - $typeBits;
if($stateBits !== $readBits){
throw new \LogicException("Exactly $stateBits bits of state data were provided, but $readBits were read");
throw new \LogicException(get_class($this) . ": Exactly $stateBits bits of state data were provided, but $readBits were read");
}
}
@ -149,7 +150,7 @@ class Block{
$this->encodeType($writer);
$writtenBits = $writer->getOffset();
if($typeBits !== $writtenBits){
throw new \LogicException("Exactly $typeBits bits of type data were expected, but $writtenBits were written");
throw new \LogicException(get_class($this) . ": Exactly $typeBits bits of type data were expected, but $writtenBits were written");
}
return $writer->getValue();
@ -168,7 +169,7 @@ class Block{
$this->encodeState($writer);
$writtenBits = $writer->getOffset() - $typeBits;
if($stateBits !== $writtenBits){
throw new \LogicException("Exactly $stateBits bits of state data were expected, but $writtenBits were written");
throw new \LogicException(get_class($this) . ": Exactly $stateBits bits of state data were expected, but $writtenBits were written");
}
return $writer->getValue();