Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/JsonSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

namespace ServiceBus\MessageSerializer;

use ServiceBus\Common\Exceptions\JsonSerializationFailed;
use ServiceBus\MessageSerializer\Exceptions\SerializationFailed;
use ServiceBus\MessageSerializer\Exceptions\UnserializeFailed;
use function ServiceBus\Common\jsonDecode;
Expand All @@ -31,12 +32,12 @@ public function serialize(array $payload): string
{
return jsonEncode($payload);
}
catch (\Throwable $throwable)
catch (JsonSerializationFailed $jsonError)
{
throw new SerializationFailed(
\sprintf('JSON serialize failed: %s', $throwable->getMessage()),
(int) $throwable->getCode(),
$throwable
\sprintf('JSON serialize failed: %s', $jsonError->getMessage()),
(int) $jsonError->getCode(),
$jsonError
);
}
}
Expand All @@ -50,12 +51,12 @@ public function unserialize(string $content): array
{
return jsonDecode($content);
}
catch (\Throwable $throwable)
catch (JsonSerializationFailed $jsonError)
{
throw new UnserializeFailed(
\sprintf('JSON unserialize failed: %s', $throwable->getMessage()),
(int) $throwable->getCode(),
$throwable
\sprintf('JSON unserialize failed: %s', $jsonError->getMessage()),
(int) $jsonError->getCode(),
$jsonError
);
}
}
Expand Down