1212
1313namespace ServiceBus \MessageSerializer ;
1414
15+ use ServiceBus \Common \Exceptions \JsonSerializationFailed ;
1516use ServiceBus \MessageSerializer \Exceptions \SerializationFailed ;
1617use ServiceBus \MessageSerializer \Exceptions \UnserializeFailed ;
1718use function ServiceBus \Common \jsonDecode ;
@@ -31,12 +32,12 @@ public function serialize(array $payload): string
3132 {
3233 return jsonEncode ($ payload );
3334 }
34- catch (\ Throwable $ throwable )
35+ catch (JsonSerializationFailed $ jsonError )
3536 {
3637 throw new SerializationFailed (
37- \sprintf ('JSON serialize failed: %s ' , $ throwable ->getMessage ()),
38- (int ) $ throwable ->getCode (),
39- $ throwable
38+ \sprintf ('JSON serialize failed: %s ' , $ jsonError ->getMessage ()),
39+ (int ) $ jsonError ->getCode (),
40+ $ jsonError
4041 );
4142 }
4243 }
@@ -50,12 +51,12 @@ public function unserialize(string $content): array
5051 {
5152 return jsonDecode ($ content );
5253 }
53- catch (\ Throwable $ throwable )
54+ catch (JsonSerializationFailed $ jsonError )
5455 {
5556 throw new UnserializeFailed (
56- \sprintf ('JSON unserialize failed: %s ' , $ throwable ->getMessage ()),
57- (int ) $ throwable ->getCode (),
58- $ throwable
57+ \sprintf ('JSON unserialize failed: %s ' , $ jsonError ->getMessage ()),
58+ (int ) $ jsonError ->getCode (),
59+ $ jsonError
5960 );
6061 }
6162 }
0 commit comments