DbObject: provide friendler not-found errors

This commit is contained in:
Thomas Gelf 2016-03-16 21:41:00 +01:00
parent af71138227
commit 4af6b11f58

View File

@ -560,12 +560,20 @@ abstract class DbObject
$properties = $this->db->fetchRow($select); $properties = $this->db->fetchRow($select);
if (empty($properties)) { if (empty($properties)) {
throw new NotFoundError(
'Got no "%s" data for: %s (%s)', if (is_array($this->getKeyName())) {
$this->table, throw new NotFoundError(
$this->getLogId(), 'Failed to load %s for %s',
$this->createWhere() $this->table,
); $this->createWhere()
);
} else {
throw new NotFoundError(
'Failed to load %s "%s"',
$this->table,
$this->getLogId()
);
}
} }
return $this->setDbProperties($properties); return $this->setDbProperties($properties);
@ -743,7 +751,6 @@ abstract class DbObject
return $result; return $result;
} }
/** /**
* Delete item from DB * Delete item from DB
* *