Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bc40f96

Browse files
committed
fixup! 10a4ddc
1 parent e585d31 commit bc40f96

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

‎src/Codec/CodecLibrary.php‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
namespace MongoDB\Codec;
44

55
use MongoDB\Exception\InvalidArgumentException;
6-
use MongoDB\Exception\UnexpectedValueException;
7-
8-
use function get_debug_type;
9-
use function sprintf;
6+
use MongoDB\Exception\UndecodableValueException;
7+
use MongoDB\Exception\UnencodableValueException;
108

119
class CodecLibrary implements Codec
1210
{
@@ -114,7 +112,7 @@ final public function decode($value)
114112
}
115113
}
116114

117-
throw new UnexpectedValueException(sprintf('No decoder found for value of type "%s"', get_debug_type($value)));
115+
throw new UndecodableValueException($value);
118116
}
119117

120118
/**
@@ -129,6 +127,6 @@ final public function encode($value)
129127
}
130128
}
131129

132-
throw new UnexpectedValueException(sprintf('No encoder found for value of type "%s"', get_debug_type($value)));
130+
throw new UnencodableValueException($value);
133131
}
134132
}

‎tests/Codec/CodecLibraryTest.php‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
use MongoDB\Codec\DecodeIfSupported;
88
use MongoDB\Codec\EncodeIfSupported;
99
use MongoDB\Codec\KnowsCodecLibrary;
10-
use MongoDB\Exception\UnexpectedValueException;
10+
use MongoDB\Exception\UndecodableValueException;
11+
use MongoDB\Exception\UnencodableValueException;
1112
use MongoDB\Tests\TestCase;
1213

1314
class CodecLibraryTest extends TestCase
@@ -36,16 +37,16 @@ public function testDecodeNull(): void
3637

3738
$this->assertFalse($codec->canDecode(null));
3839

39-
$this->expectException(UnexpectedValueException::class);
40-
$this->expectExceptionMessage('No decoder found for value of type "null"');
40+
$this->expectException(UndecodableValueException::class);
41+
$this->expectExceptionMessage('Could not decode value of type "null"');
4142

4243
$this->assertNull($codec->decode(null));
4344
}
4445

4546
public function testDecodeUnsupportedValue(): void
4647
{
47-
$this->expectException(UnexpectedValueException::class);
48-
$this->expectExceptionMessage('No decoder found for value of type "string"');
48+
$this->expectException(UndecodableValueException::class);
49+
$this->expectExceptionMessage('Could not decode value of type "string"');
4950

5051
$this->getCodecLibrary()->decode('foo');
5152
}
@@ -74,16 +75,16 @@ public function testEncodeNull(): void
7475

7576
$this->assertFalse($codec->canEncode(null));
7677

77-
$this->expectException(UnexpectedValueException::class);
78-
$this->expectExceptionMessage('No encoder found for value of type "null"');
78+
$this->expectException(UnencodableValueException::class);
79+
$this->expectExceptionMessage('Could not encode value of type "null"');
7980

8081
$codec->encode(null);
8182
}
8283

8384
public function testEncodeUnsupportedValue(): void
8485
{
85-
$this->expectException(UnexpectedValueException::class);
86-
$this->expectExceptionMessage('No encoder found for value of type "string"');
86+
$this->expectException(UnencodableValueException::class);
87+
$this->expectExceptionMessage('Could not encode value of type "string"');
8788

8889
$this->getCodecLibrary()->encode('foo');
8990
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /