From 7861b012b05e4bf7abc987e02c544f46c833f86f Mon Sep 17 00:00:00 2001 From: Cody Reichert Date: Tue, 19 Apr 2022 19:20:46 -0500 Subject: [PATCH] Fix error handling when listing details are unavailable --- src/simply-rets-api-helper.php | 6 +++++- src/simply-rets-utils.php | 7 +++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/simply-rets-api-helper.php b/src/simply-rets-api-helper.php index 2157fa4..c48ff2c 100644 --- a/src/simply-rets-api-helper.php +++ b/src/simply-rets-api-helper.php @@ -581,9 +581,13 @@ public static function srResidentialDetailsGenerator( $listing ) { * The error code comes from the UrlBuilder function. */ if($listing == NULL + || property_exists($listing, "message") || property_exists($listing, "error") || property_exists($listing, "errors")) { - $err = SrMessages::noResultsMsg((array)$listing); + $err = SrMessages::noResultsMsg( + (array)$listing, + "Details for this listing are no longer available." + ); return $err; } diff --git a/src/simply-rets-utils.php b/src/simply-rets-utils.php index 1e45672..3333d6b 100644 --- a/src/simply-rets-utils.php +++ b/src/simply-rets-utils.php @@ -530,14 +530,13 @@ public static function getBathroomsDisplay( class SrMessages { - public static function noResultsMsg($response) { + public static function noResultsMsg($response, $msg) { $response = (array)$response; + $message = $msg ? $msg : $response['message']; if(array_key_exists("message", $response)) { return ( - '

' - . $response['message'] - . '

' + '

' . $message . '

' ); }