Procházet zdrojové kódy

try catch dbo deserialize

tags/0.1.4^0
Robin Thoni před 8 roky
rodič
revize
124e449f3a
1 změnil soubory, kde provedl 10 přidání a 2 odebrání
  1. 10
    2
      src/Utils/LuRoute.php

+ 10
- 2
src/Utils/LuRoute.php Zobrazit soubor

@@ -63,8 +63,16 @@ class LuRoute {
63 63
         }
64 64
         else {
65 65
             $class = $param->getClass();
66
-            $json = json_decode($value, true);
67
-            $typedValue = call_user_func_array(array($class->getName(), "jsonDeserialize"), array($json));
66
+            try
67
+            {
68
+                $json = json_decode($value, true);
69
+                $typedValue = call_user_func_array(array($class->getName(), "jsonDeserialize"), array($json));
70
+            }
71
+            catch (\Exception $e)
72
+            {
73
+                LuLog::log($e);
74
+                LuBusiness::badInput("Unable to parse JSON value for " . $param->getName());
75
+            }
68 76
         }
69 77
         return $typedValue;
70 78
     }

Načítá se…
Zrušit
Uložit