TextFormat: account for failure to encode JSON in toJSON()

This commit is contained in:
Dylan K. Taylor 2020-04-15 11:29:50 +01:00
parent 41d7b8c0e4
commit d246933e3e

View File

@ -288,7 +288,11 @@ abstract class TextFormat{
}
}
return json_encode($newString, JSON_UNESCAPED_SLASHES);
$result = json_encode($newString, JSON_UNESCAPED_SLASHES);
if($result === false){
throw new \InvalidArgumentException("Failed to encode result JSON: " . json_last_error_msg());
}
return $result;
}
/**