Commit 9c108d5a authored by Jeremy Mikola's avatar Jeremy Mikola

Split UnexpectedTypeException for logic and runtime errors

Invalid arguments and options constitute a logic error, so InvalidArgumentTypeException may be used. For runtime errors (e.g. server returned something we didn't expect), UnexpectedValueTypeException may be used.
parent 64c40145
<?php
namespace MongoDB\Exception;
class InvalidArgumentTypeException extends InvalidArgumentException
{
public function __construct($name, $value, $expectedType)
{
parent::__construct(sprintf('Expected %s to have type "%s" but found "%s"', $name, $expectedType, is_object($value) ? get_class($value) : gettype($value)));
}
}
<?php
namespace MongoDB\Exception;
class UnexpectedValueTypeException extends UnexpectedValueException
{
public function __construct($name, $value, $expectedType)
{
parent::__construct(sprintf('Expected %s to have type "%s" but found "%s"', $name, $expectedType, is_object($value) ? get_class($value) : gettype($value)));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment