Skip to content

Commit 9b13b5f

Browse files
committed
refactor: refactored abstract Serializer
1 parent 6398fc8 commit 9b13b5f

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/Serializer/Serializer.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ public function serialize(mixed $serializable): string
1212
{
1313
try {
1414
return $this->doSerialize($serializable);
15+
} catch (Exception\SerializerCouldNotSerializeData $exception) {
16+
throw $exception;
1517
} catch (Throwable $reason) {
16-
if ($reason instanceof Exception\SerializerCouldNotSerializeData) {
17-
throw $reason;
18-
}
1918
throw new Exception\SerializerCouldNotSerializeData(__METHOD__, $serializable, $reason);
2019
}
2120
}
@@ -24,10 +23,9 @@ public function unserialize(string $serialized): mixed
2423
{
2524
try {
2625
return $this->doUnserialize($serialized);
26+
} catch (Exception\SerializerCouldNotUnserializeData $exception) {
27+
throw $exception;
2728
} catch (Throwable $reason) {
28-
if ($reason instanceof Exception\SerializerCouldNotUnserializeData) {
29-
throw $reason;
30-
}
3129
throw new Exception\SerializerCouldNotUnserializeData(__METHOD__, $serialized, $reason);
3230
}
3331
}

0 commit comments

Comments
 (0)