From bc75bcb53c112c110b59203699bb12f0881ea4b5 Mon Sep 17 00:00:00 2001 From: Bjverde Date: Tue, 27 Sep 2022 16:15:50 -0300 Subject: [PATCH] :bug: BASE #270 colocando try cat --- .../Acesso_perfilAPI.class.php | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/appexemplo_v2.0/api/api_controllers/Acesso_perfilAPI.class.php b/appexemplo_v2.0/api/api_controllers/Acesso_perfilAPI.class.php index add56ff0..0a49d2ff 100644 --- a/appexemplo_v2.0/api/api_controllers/Acesso_perfilAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/Acesso_perfilAPI.class.php @@ -25,14 +25,20 @@ public function __construct() //-------------------------------------------------------------------------------- public static function selectAll(Request $request, Response $response, array $args) { - $controller = new \Acesso_perfil(); - $result = $controller->selectAll(); - $result = \ArrayHelper::convertArrayFormDin2Pdo($result); - $msg = array( 'qtd'=> \CountHelper::count($result) - , 'result'=>$result - ); - $response = TGenericAPI::getBodyJson($msg,$response,200); - return $response; + try{ + $controller = new \Acesso_perfil(); + $result = $controller->selectAll(); + $result = \ArrayHelper::convertArrayFormDin2Pdo($result); + $msg = array( 'qtd'=> \CountHelper::count($result) + , 'result'=>$result + ); + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } //-------------------------------------------------------------------------------- private static function selectByIdInside(array $args) @@ -46,13 +52,18 @@ private static function selectByIdInside(array $args) //-------------------------------------------------------------------------------- public static function selectById(Request $request, Response $response, array $args) { - $result = self::selectByIdInside($args); - $msg = array( 'qtd'=> \CountHelper::count($result) - , 'result'=>$result - ); - - $response = TGenericAPI::getBodyJson($msg,$response); - return $response; + try{ + $result = self::selectByIdInside($args); + $msg = array( 'qtd'=> \CountHelper::count($result) + , 'result'=>$result + ); + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } //-------------------------------------------------------------------------------- public static function save(Request $request, Response $response, array $args)