summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2016-01-14 10:38:53 +0100
committerMorris Jobke <hey@morrisjobke.de>2016-01-14 10:40:23 +0100
commit86f08f59d6318a45a20b74e4b2b449ddc6882419 (patch)
tree2ea3cf84cdc6596110144a14976243839926b2e6
parent64c8427d813445aceb019c08a417633ace17d366 (diff)
downloadnextcloud-server-86f08f59d6318a45a20b74e4b2b449ddc6882419.tar.gz
nextcloud-server-86f08f59d6318a45a20b74e4b2b449ddc6882419.zip
use logException() to properly log the exception
-rw-r--r--lib/private/backgroundjob/job.php3
-rw-r--r--tests/lib/backgroundjob/job.php10
2 files changed, 9 insertions, 4 deletions
diff --git a/lib/private/backgroundjob/job.php b/lib/private/backgroundjob/job.php
index 4c4da94d4fd..d666cfe085e 100644
--- a/lib/private/backgroundjob/job.php
+++ b/lib/private/backgroundjob/job.php
@@ -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);
}
}
}
diff --git a/tests/lib/backgroundjob/job.php b/tests/lib/backgroundjob/job.php
index f2a5ff894fe..75b4865819a 100644
--- a/tests/lib/backgroundjob/job.php
+++ b/tests/lib/backgroundjob/job.php
@@ -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);