File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
lib/internal/Magento/Framework/Serialize/Serializer Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change 15
15
*/
16
16
class Json implements SerializerInterface
17
17
{
18
+ private $ appState = NULL ;
19
+
20
+ public function __construct (){
21
+ $ objectManager = \Magento \Framework \App \ObjectManager::getInstance ();
22
+ $ this ->appState = $ this ->objectmanager ->get ('Magento\Framework\App\State ' );
23
+ }
18
24
/**
19
25
* {@inheritDoc}
20
26
* @since 100.2.0
@@ -23,7 +29,11 @@ public function serialize($data)
23
29
{
24
30
$ result = json_encode ($ data );
25
31
if (false === $ result ) {
26
- throw new \InvalidArgumentException ('Unable to serialize value. ' );
32
+ $ errorMessage = "Unable to serialize value. " ;
33
+ if (!$ this ->isOnProduction ()){
34
+ $ errorMessage .= "Error: " . json_last_error_msg ();
35
+ }
36
+ throw new \InvalidArgumentException ($ errorMessage );
27
37
}
28
38
return $ result ;
29
39
}
@@ -36,8 +46,16 @@ public function unserialize($string)
36
46
{
37
47
$ result = json_decode ($ string , true );
38
48
if (json_last_error () !== JSON_ERROR_NONE ) {
39
- throw new \InvalidArgumentException ('Unable to unserialize value. ' );
49
+ $ errorMessage = "Unable to unserialize value. " ;
50
+ if (!$ this ->isOnProduction ()){
51
+ $ errorMessage .= "Error: " . json_last_error_msg ();
52
+ }
53
+ throw new \InvalidArgumentException ($ errorMessage );
40
54
}
41
55
return $ result ;
42
56
}
57
+
58
+ private function isOnProduction (){
59
+ return $ this ->appState === \Magento \Framework \App \State::MODE_PRODUCTION ;
60
+ }
43
61
}
You can’t perform that action at this time.
0 commit comments