tw: don't catch and throw

Signed-off-by: Varun Patil <varunpatil@ucla.edu>
pull/579/head
Varun Patil 2023-04-15 11:32:02 -07:00
parent d8f18abf30
commit 5fe7eb9be4
2 changed files with 20 additions and 28 deletions

View File

@ -126,22 +126,18 @@ class LivePhoto
'orphan' => $query->createNamedParameter(false, IQueryBuilder::PARAM_BOOL),
];
try {
if ($prevRow) {
$query->update('memories_livephoto')
->where($query->expr()->eq('fileid', $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)))
;
foreach ($params as $key => $value) {
$query->set($key, $value);
}
} else {
$query->insert('memories_livephoto')->values($params);
if ($prevRow) {
$query->update('memories_livephoto')
->where($query->expr()->eq('fileid', $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)))
;
foreach ($params as $key => $value) {
$query->set($key, $value);
}
return $query->executeStatement() > 0;
} catch (\Exception $ex) {
throw new \Exception('Failed to create livephoto record: '.$ex->getMessage());
} else {
$query->insert('memories_livephoto')->values($params);
}
return $query->executeStatement() > 0;
}
/**

View File

@ -136,22 +136,18 @@ class TimelineWrite
// There is no easy way to UPSERT in standard SQL
// https://stackoverflow.com/questions/15252213/sql-standard-upsert-call
try {
if ($prevRow) {
$query->update('memories')
->where($query->expr()->eq('fileid', $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)))
;
foreach ($params as $key => $value) {
$query->set($key, $value);
}
} else {
$query->insert('memories')->values($params);
if ($prevRow) {
$query->update('memories')
->where($query->expr()->eq('fileid', $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)))
;
foreach ($params as $key => $value) {
$query->set($key, $value);
}
return $query->executeStatement() > 0;
} catch (\Exception $ex) {
throw new \Exception('Failed to create memories record: '.$ex->getMessage());
} else {
$query->insert('memories')->values($params);
}
return $query->executeStatement() > 0;
}
/**