Skip to content

Commit

Permalink
fix: throw error if json encoding failed
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfbecker committed Oct 28, 2017
1 parent d21aea2 commit 29f1d8c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public static function parse(string $msg): Message

public function __toString(): string
{
return json_encode($this);
$encoded = json_encode($this);
if ($encoded === false) {
throw new Error(json_last_error_msg(), ErrorCode::INTERNAL_ERROR);
}
return $encoded;
}
}

0 comments on commit 29f1d8c

Please sign in to comment.