From 4af6b11f58fa4513ef502a4989758e10474c98da Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 16 Mar 2016 21:41:00 +0100 Subject: [PATCH] DbObject: provide friendler not-found errors --- library/Director/Data/Db/DbObject.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/library/Director/Data/Db/DbObject.php b/library/Director/Data/Db/DbObject.php index 014fa535..453146c8 100644 --- a/library/Director/Data/Db/DbObject.php +++ b/library/Director/Data/Db/DbObject.php @@ -560,12 +560,20 @@ abstract class DbObject $properties = $this->db->fetchRow($select); if (empty($properties)) { - throw new NotFoundError( - 'Got no "%s" data for: %s (%s)', - $this->table, - $this->getLogId(), - $this->createWhere() - ); + + if (is_array($this->getKeyName())) { + throw new NotFoundError( + 'Failed to load %s for %s', + $this->table, + $this->createWhere() + ); + } else { + throw new NotFoundError( + 'Failed to load %s "%s"', + $this->table, + $this->getLogId() + ); + } } return $this->setDbProperties($properties); @@ -743,7 +751,6 @@ abstract class DbObject return $result; } - /** * Delete item from DB *