diff --git a/lib/Skeleton/Transaction/Log.php b/lib/Skeleton/Transaction/Log.php index 5eda3c1..18d7147 100644 --- a/lib/Skeleton/Transaction/Log.php +++ b/lib/Skeleton/Transaction/Log.php @@ -89,8 +89,7 @@ public static function get_last_successful() { * Create log. */ public static function create( - \Transaction $transaction, bool $failed, string $output = '', ?\Throwable $t = null, - ?string $date = null + \Transaction $transaction, bool $failed, string $output = '', ?string $date = null ): self { $log = new self(); @@ -98,10 +97,6 @@ public static function create( $log->failed = $failed; $log->output = $output; - if (isset($t) === true) { - $log->exception = print_r($t, true); - } - if ($date !== null) { $log->created = (new \DateTime($date))->format('Y-m-d H:i:s'); } diff --git a/lib/Skeleton/Transaction/Retry.php b/lib/Skeleton/Transaction/Retry.php index 32f6bde..d89ede2 100644 --- a/lib/Skeleton/Transaction/Retry.php +++ b/lib/Skeleton/Transaction/Retry.php @@ -23,17 +23,15 @@ trait Retry { * Retry transaction after a specified time (default: 15 minutes) * * @access public - * @param \Exception $exception * @param string $output * @param string $next_retry */ - public function retry(\Exception $exception = null, $output = null, $next_retry = '+15 minutes') { + public function retry($output = null, $next_retry = '+15 minutes') { if (self::$max_attempts > 0 && $this->retry_attempt >= self::$max_attempts) { - echo $output; - throw $exception; + throw new \Exception($output); } - Log::create($this, true, $output, $exception); + Log::create($this, true, $output); $this->retry_attempt++; $this->schedule($next_retry); @@ -43,18 +41,16 @@ public function retry(\Exception $exception = null, $output = null, $next_retry * Retry transaction using an incremental time algorithm * * @access public - * @param \Exception $exception * @param string $output * @param int $exp * @param string $unit */ - public function retry_incremental(\Exception $exception = null, $output = null, $exp = 2, $unit = 'minutes') { + public function retry_incremental($output = null, $exp = 2, $unit = 'minutes') { if (self::$max_attempts > 0 && $this->retry_attempt >= self::$max_attempts) { - echo $output; - throw $exception; + throw new \Exception($output); } - Log::create($this, true, $output, $exception); + Log::create($this, true, $output); $this->retry_attempt++; $this->schedule(pow($this->retry_attempt, $exp) . ' ' . $unit); diff --git a/lib/Skeleton/Transaction/Transaction.php b/lib/Skeleton/Transaction/Transaction.php index d3f4c7e..352ea2d 100644 --- a/lib/Skeleton/Transaction/Transaction.php +++ b/lib/Skeleton/Transaction/Transaction.php @@ -209,7 +209,7 @@ public function unlock() { * @access public */ public function mark_failed($output, $exception, $date = null) { - Log::create($this, true, $output, $exception, $date); + Log::create($this, true, print_r($exception, true), $date); $this->failed = true; $this->completed = true; @@ -229,8 +229,8 @@ public function mark_failed($output, $exception, $date = null) { * @param string $date */ public function mark_completed($output, $date = null) { - Log::create($this, false, $output, null, $date); - + Log::create($this, false, $output, $date); + // Don't mark this transaction as completed if it has been rescheduled. if ($this->rescheduled) { return;