Skip to content

Commit 7861b01

Browse files
committed
Fix error handling when listing details are unavailable
1 parent 24634c4 commit 7861b01

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/simply-rets-api-helper.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,9 +581,13 @@ public static function srResidentialDetailsGenerator( $listing ) {
581581
* The error code comes from the UrlBuilder function.
582582
*/
583583
if($listing == NULL
584+
|| property_exists($listing, "message")
584585
|| property_exists($listing, "error")
585586
|| property_exists($listing, "errors")) {
586-
$err = SrMessages::noResultsMsg((array)$listing);
587+
$err = SrMessages::noResultsMsg(
588+
(array)$listing,
589+
"Details for this listing are no longer available."
590+
);
587591
return $err;
588592
}
589593

src/simply-rets-utils.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,14 +530,13 @@ public static function getBathroomsDisplay(
530530

531531
class SrMessages {
532532

533-
public static function noResultsMsg($response) {
533+
public static function noResultsMsg($response, $msg) {
534534

535535
$response = (array)$response;
536+
$message = $msg ? $msg : $response['message'];
536537
if(array_key_exists("message", $response)) {
537538
return (
538-
'<br><p><strong>'
539-
. $response['message']
540-
. '</br></p></strong>'
539+
'<br><p><strong>' . $message . '</br></p></strong>'
541540
);
542541
}
543542

0 commit comments

Comments
 (0)