mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 20:07:09 +00:00
Block: add the current class to the exception messages for block runtime data serialization
This commit is contained in:
parent
8b2d941502
commit
20cb67461f
@ -47,6 +47,7 @@ use pocketmine\world\format\Chunk;
|
|||||||
use pocketmine\world\Position;
|
use pocketmine\world\Position;
|
||||||
use pocketmine\world\World;
|
use pocketmine\world\World;
|
||||||
use function count;
|
use function count;
|
||||||
|
use function get_class;
|
||||||
use const PHP_INT_MAX;
|
use const PHP_INT_MAX;
|
||||||
|
|
||||||
class Block{
|
class Block{
|
||||||
@ -109,7 +110,7 @@ class Block{
|
|||||||
$this->decodeType($reader);
|
$this->decodeType($reader);
|
||||||
$readBits = $reader->getOffset();
|
$readBits = $reader->getOffset();
|
||||||
if($typeBits !== $readBits){
|
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);
|
$this->decodeState($reader);
|
||||||
$readBits = $reader->getOffset() - $typeBits;
|
$readBits = $reader->getOffset() - $typeBits;
|
||||||
if($stateBits !== $readBits){
|
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);
|
$this->encodeType($writer);
|
||||||
$writtenBits = $writer->getOffset();
|
$writtenBits = $writer->getOffset();
|
||||||
if($typeBits !== $writtenBits){
|
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();
|
return $writer->getValue();
|
||||||
@ -168,7 +169,7 @@ class Block{
|
|||||||
$this->encodeState($writer);
|
$this->encodeState($writer);
|
||||||
$writtenBits = $writer->getOffset() - $typeBits;
|
$writtenBits = $writer->getOffset() - $typeBits;
|
||||||
if($stateBits !== $writtenBits){
|
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();
|
return $writer->getValue();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user