Added more error checking in add()
This commit is contained in:
parent
8fab9eef28
commit
8a02afd87a
12
lib/tags.php
12
lib/tags.php
|
@ -233,12 +233,20 @@ class Tags implements \OCP\ITags {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
\OCP\DB::insertIfNotExist(self::TAG_TABLE,
|
$result = \OCP\DB::insertIfNotExist(
|
||||||
|
self::TAG_TABLE,
|
||||||
array(
|
array(
|
||||||
'uid' => $this->user,
|
'uid' => $this->user,
|
||||||
'type' => $this->type,
|
'type' => $this->type,
|
||||||
'category' => $name,
|
'category' => $name,
|
||||||
));
|
)
|
||||||
|
);
|
||||||
|
if (\OCP\DB::isError($result)) {
|
||||||
|
\OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage($result), \OCP\Util::ERROR);
|
||||||
|
return false;
|
||||||
|
} elseif((int)$result === 0) {
|
||||||
|
\OCP\Util::writeLog('core', __METHOD__.', Tag already exists: ' . $name, \OCP\Util::DEBUG);
|
||||||
|
}
|
||||||
} catch(\Exception $e) {
|
} catch(\Exception $e) {
|
||||||
\OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
|
\OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
|
||||||
\OCP\Util::ERROR);
|
\OCP\Util::ERROR);
|
||||||
|
|
Loading…
Reference in New Issue