!385 基于PHP7.1版本使用Catch多个语句

Merge pull request !385 from Henry/optimiza-exception-handle
pull/390/MERGE
F4nniu 2022-04-02 09:13:44 +00:00 committed by Gitee
commit 9116b86a36
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 6 additions and 30 deletions

View File

@ -110,13 +110,7 @@ trait Backend
}
$result = $this->model->allowField(true)->save($params);
Db::commit();
} catch (ValidateException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
@ -161,13 +155,7 @@ trait Backend
}
$result = $row->allowField(true)->save($params);
Db::commit();
} catch (ValidateException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
@ -207,10 +195,7 @@ trait Backend
$count += $v->delete();
}
Db::commit();
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
} catch (PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
@ -248,10 +233,7 @@ trait Backend
$count += $v->delete(true);
}
Db::commit();
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
} catch (PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
@ -288,10 +270,7 @@ trait Backend
$count += $item->restore();
}
Db::commit();
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
} catch (PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
@ -327,10 +306,7 @@ trait Backend
$count += $item->allowField(true)->isUpdate(true)->save($values);
}
Db::commit();
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
} catch (PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}