Skip to content
Snippets Groups Projects
Commit 0b4de847 authored by Thomas Tanghus's avatar Thomas Tanghus
Browse files

Added more error checking in add()

parent de81210b
Branches
No related tags found
No related merge requests found
......@@ -233,12 +233,20 @@ class Tags implements \OCP\ITags {
return false;
}
try {
\OCP\DB::insertIfNotExist(self::TAG_TABLE,
$result = \OCP\DB::insertIfNotExist(
self::TAG_TABLE,
array(
'uid' => $this->user,
'type' => $this->type,
'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) {
\OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
\OCP\Util::ERROR);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment