Skip to content

Commit

Permalink
fix: Fix to Line Numbers in Exception Logging
Browse files Browse the repository at this point in the history
  • Loading branch information
usernane committed Jul 2, 2024
1 parent 0baf386 commit 781a233
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
25 changes: 13 additions & 12 deletions tests/webfiori/framework/test/cli/SchedulerCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,21 +172,22 @@ public function test05() {
"Thrown in: Fail2TestTask\n",
"Line: 44\n",
"Stack Trace:\n",
"#0 At class app\\tasks\Fail2TestTask line 1083\n",
"#1 At class webfiori\\framework\scheduler\AbstractTask line 406\n",
"#2 At class webfiori\\framework\scheduler\AbstractTask line 903\n",
"#3 At class webfiori\\framework\scheduler\TasksManager line 625\n",
"#4 At class webfiori\\framework\scheduler\TasksManager line 135\n",
"#5 At class webfiori\\framework\cli\commands\SchedulerCommand line 86\n",
"#6 At class webfiori\\framework\cli\commands\SchedulerCommand line 328\n",
"#7 At class webfiori\\cli\CLICommand line 409\n",
"#8 At class webfiori\\cli\Runner line 684\n",
"#9 At class webfiori\\cli\Runner line 615\n",
"#10 At class webfiori\cli\Runner line 154\n",
"#0 At class app\\tasks\Fail2TestTask line 44\n",
"#1 At class webfiori\\framework\scheduler\AbstractTask line 1097\n",
"#2 At class webfiori\\framework\scheduler\AbstractTask line 418\n",
"#3 At class webfiori\\framework\scheduler\AbstractTask line 951\n",
"#4 At class webfiori\\framework\scheduler\TasksManager line 673\n",
"#5 At class webfiori\\framework\scheduler\TasksManager line 139\n",
"#6 At class webfiori\\framework\cli\commands\SchedulerCommand line 86\n",
"#7 At class webfiori\\framework\cli\commands\SchedulerCommand line 328\n",
"#8 At class webfiori\\cli\CLICommand line 409\n",
"#9 At class webfiori\\cli\Runner line 684\n",
"#10 At class webfiori\\cli\Runner line 615\n",
"#11 At class webfiori\cli\Runner line 156\n",
"Skip"];
$actual = $runner->getOutput();
$idx = 0;

var_dump($actual);
foreach ($expected as $item) {
if ($item == 'Skip') {
break;
Expand Down
10 changes: 8 additions & 2 deletions webfiori/framework/scheduler/AbstractTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -1525,8 +1525,14 @@ private function logExeException(Throwable $ex, string $meth = '') {
TasksManager::log('Line: '.$ex->getLine());
TasksManager::log('Stack Trace:');
$index = 0;

foreach ($ex->getTrace() as $traceEntry) {
$trace = debug_backtrace();
$firstEntry = $ex->getTrace()[0];
$firstEntry['line'] = $ex->getLine();
$e = new TraceEntry($firstEntry);
TasksManager::log('#'.$index.' '.$e);
$index++;

foreach ($trace as $traceEntry) {
$e = new TraceEntry($traceEntry);
TasksManager::log('#'.$index.' '.$e);
$index++;
Expand Down

0 comments on commit 781a233

Please sign in to comment.