Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ziaratban committed Feb 8, 2025
1 parent 2905bbd commit 6c5f8cd
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function safeRollBack(&$exception = null)
}
}

public function run($query, $throw = false, $log = true, $commit = false, $queue = false){
public function run($query, $throw = false, $log = true, $commit = false, $queue = false, $logExceptions = []){

if($queue === true){
$this->queue[] = $query;
Expand All @@ -233,9 +233,24 @@ public function run($query, $throw = false, $log = true, $commit = false, $queue
}
catch(\Throwable $e) {
$this->lastRunError = $e;

if(!YII_ENV_PROD || $log) {
Yii::error($e);
$log = true;

foreach($logExceptions as $logExceptionClass => $messagePattern){
if(
$e instanceof $logExceptionClass
&&
preg_match($messagePattern, $e->GetMessage(), $_) === 1
){
$log = false;
}
}

if($log)
Yii::error($e);
}

if(!YII_ENV_PROD || $throw) {
throw $e;
}
Expand Down

0 comments on commit 6c5f8cd

Please sign in to comment.