DbQuery: Catch exceptions in __toString()

This commit is contained in:
Johannes Meyer 2015-11-12 16:32:29 +01:00
parent 140e288c0b
commit b182a31b90
1 changed files with 9 additions and 2 deletions

View File

@ -3,7 +3,9 @@
namespace Icinga\Data\Db;
use Exception;
use Zend_Db_Select;
use Icinga\Application\Logger;
use Icinga\Data\Filter\FilterAnd;
use Icinga\Data\Filter\FilterChain;
use Icinga\Data\Filter\FilterNot;
@ -382,8 +384,13 @@ class DbQuery extends SimpleQuery
*/
public function __toString()
{
try {
$select = (string) $this->getSelectQuery();
return $this->getIsSubQuery() ? ('(' . $select . ')') : $select;
} catch (Exception $e) {
Logger::debug('Failed to render DbQuery. An error occured: %s', $e);
return '';
}
}
/**