Skip to content

Commit 29f1d8c

Browse files
committed
fix: throw error if json encoding failed
1 parent d21aea2 commit 29f1d8c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/Message.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ public static function parse(string $msg): Message
4343

4444
public function __toString(): string
4545
{
46-
return json_encode($this);
46+
$encoded = json_encode($this);
47+
if ($encoded === false) {
48+
throw new Error(json_last_error_msg(), ErrorCode::INTERNAL_ERROR);
49+
}
50+
return $encoded;
4751
}
4852
}

0 commit comments

Comments
 (0)