mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
use logException() to properly log the exception
This commit is contained in:
parent
64c8427d81
commit
86f08f59d6
2 changed files with 9 additions and 4 deletions
|
|
@ -52,7 +52,8 @@ abstract class Job implements IJob {
|
|||
$this->run($this->argument);
|
||||
} catch (\Exception $e) {
|
||||
if ($logger) {
|
||||
$logger->error('Error while running background job (class: ' . get_class($this) . ', arguments: ' . print_r($this->argument, true) . '): ' . $e->getMessage());
|
||||
$logger->error('Error while running background job (class: ' . get_class($this) . ', arguments: ' . print_r($this->argument, true) . ')');
|
||||
$logger->logException($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,8 +18,9 @@ class Job extends \Test\TestCase {
|
|||
|
||||
public function testRemoveAfterException() {
|
||||
$jobList = new DummyJobList();
|
||||
$job = new TestJob($this, function () {
|
||||
throw new \Exception();
|
||||
$e = new \Exception();
|
||||
$job = new TestJob($this, function () use ($e) {
|
||||
throw $e;
|
||||
});
|
||||
$jobList->add($job);
|
||||
|
||||
|
|
@ -28,7 +29,10 @@ class Job extends \Test\TestCase {
|
|||
->getMock();
|
||||
$logger->expects($this->once())
|
||||
->method('error')
|
||||
->with('Error while running background job (class: Test\BackgroundJob\TestJob, arguments: ): ');
|
||||
->with('Error while running background job (class: Test\BackgroundJob\TestJob, arguments: )');
|
||||
$logger->expects($this->once())
|
||||
->method('logException')
|
||||
->with($e);
|
||||
|
||||
$this->assertCount(1, $jobList->getAll());
|
||||
$job->execute($jobList, $logger);
|
||||
|
|
|
|||
Loading…
Reference in a new issue