From 98ae7274d252560fb3b155748ac1248f7aedc990 Mon Sep 17 00:00:00 2001 From: Thuc Nguyen Date: Tue, 16 Dec 2025 16:01:13 +0700 Subject: [PATCH] Medium: nformation Exposure - Server Error Message Signed-off-by: Thuc Nguyen --- src/RedNovaLabs/Storedge/SDK.php | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/RedNovaLabs/Storedge/SDK.php b/src/RedNovaLabs/Storedge/SDK.php index ed64793..4439977 100755 --- a/src/RedNovaLabs/Storedge/SDK.php +++ b/src/RedNovaLabs/Storedge/SDK.php @@ -233,7 +233,7 @@ public function getLeads($facility_uuid, $options) try { return $this->get($base_url . $facility_uuid . '/leads' . $query); } catch (BaseException $e) { - echo $e->getMessage(); + $this->logErrorAndShowMessage($e); } } @@ -242,7 +242,7 @@ public function createLead($facility_uuid, array $data) try { return $this->post($base_url . $facility_uuid . '/leads', $data); } catch (BaseException $e) { - echo $e->getMessage(); + $this->logErrorAndShowMessage($e); } } @@ -251,7 +251,7 @@ public function deleteLead($facility_uuid, $lead_uuid, $params) try { return $this->delete($base_url . $facility_uuid . '/leads/' . $lead_uuid, $params); } catch (BaseException $e) { - echo $e->getMessage(); + $this->logErrorAndShowMessage($e); } } @@ -262,7 +262,7 @@ public function updateTenantPATCH($facility_uuid, $tenant_uuid, array $data) try { return $this->patch($base_url . $facility_uuid . '/tenants/' . $tenant_uuid, $data); } catch (BaseException $e) { - echo $e->getMessage(); + $this->logErrorAndShowMessage($e); } } @@ -272,7 +272,7 @@ public function updateTenantPUT($facility_uuid, $tenant_uuid, array $data) try { return $this->put($base_url . $facility_uuid . '/tenants/' . $tenant_uuid, $data); } catch (BaseException $e) { - echo $e->getMessage(); + $this->logErrorAndShowMessage($e); } } @@ -281,7 +281,7 @@ public function signUpTenant($facility_uuid, $tenant_uuid, array $data) try { return $this->post($base_url . $facility_uuid . '/tenants/' . $tenant_uuid . '/sign_up', $data); } catch (BaseException $e) { - echo $e->getMessage(); + $this->logErrorAndShowMessage($e); } } @@ -290,7 +290,7 @@ public function changeTenantPassword($facility_uuid, $tenant_uuid, array $data) try { return $this->put($base_url . $facility_uuid . '/tenants/' . $tenant_uuid . '/change_password', $data); } catch (BaseException $e) { - echo $e->getMessage(); + $this->logErrorAndShowMessage($e); } } @@ -304,7 +304,7 @@ public function getUnitGroups($facility_uuid, $options) try { return $this->get($base_url . $facility_uuid . '/unit_groups' . $query); } catch (BaseException $e) { - echo $e->getMessage(); + $this->logErrorAndShowMessage($e); } } @@ -317,7 +317,7 @@ public function getSpecificUnitGroup($facility_uuid, $unit_group_uuid, $options) try { return $this->get($base_url . $facility_uuid . '/unit_groups/' . $unit_group_uuid . $query); } catch (BaseException $e) { - echo $e->getMessage(); + $this->logErrorAndShowMessage($e); } } @@ -330,7 +330,7 @@ public function getUnitGroupUnits($facility_uuid, $unit_group_uuid, $options) try { return $this->get($base_url . $facility_uuid . '/unit_groups/' . $unit_group_uuid . '/units' . $query); } catch (BaseException $e) { - echo $e->getMessage(); + $this->logErrorAndShowMessage($e); } } @@ -344,7 +344,7 @@ public function getUnits($facility_uuid, $options) try { return $this->get($base_url . $facility_uuid . '/units' . $query); } catch (BaseException $e) { - echo $e->getMessage(); + $this->logErrorAndShowMessage($e); } } @@ -357,7 +357,7 @@ public function getAvailableUnits($facility_uuid, $options) try { return $this->get($base_url . $facility_uuid . '/units/available' . $query); } catch (BaseException $e) { - echo $e->getMessage(); + $this->logErrorAndShowMessage($e); } } @@ -370,8 +370,14 @@ public function getSpecificUnit($facility_uuid, $unit_uuid, $options) try { return $this->get($base_url . $facility_uuid . '/units/' . $unit_uuid . $query); } catch (BaseException $e) { - echo $e->getMessage(); + $this->logErrorAndShowMessage($e); } } + private function logErrorAndShowMessage($e) + { + error_log($e->getMessage()); + echo("Something went wrong with API request. Check error log for details.\n"); + } + }