Skip to content

Commit

Permalink
Updated to show error message to all Env.
Browse files Browse the repository at this point in the history
  • Loading branch information
vinogcs authored Dec 28, 2018
1 parent 143120b commit ac407de
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions lib/internal/Magento/Framework/Serialize/Serializer/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ public function serialize($data)
{
$result = json_encode($data);
if (false === $result) {
$errorMessage = "Unable to serialize value.";
if(!$this->isOnProduction()){
$errorMessage .= "Error: " . json_last_error_msg();
}
throw new \InvalidArgumentException($errorMessage);
throw new \InvalidArgumentException("Unable to serialize value. Error: " . json_last_error_msg());
}
return $result;
}
Expand All @@ -40,18 +36,8 @@ public function unserialize($string)
{
$result = json_decode($string, true);
if (json_last_error() !== JSON_ERROR_NONE) {
$errorMessage = "Unable to unserialize value.";
if(!$this->isOnProduction()){
$errorMessage .= "Error: " . json_last_error_msg();
}
throw new \InvalidArgumentException($errorMessage);
throw new \InvalidArgumentException("Unable to unserialize value. Error: " . json_last_error_msg());
}
return $result;
}

private function isOnProduction(){
$appState = \Magento\Framework\App\ObjectManager::getInstance()
->get('Magento\Framework\App\State');
return $appState === \Magento\Framework\App\State::MODE_PRODUCTION;
}
}
}

0 comments on commit ac407de

Please sign in to comment.