summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2017-11-14 14:28:04 +0100
committerChristoph Wurst <christoph@winzerhof-wurst.at>2017-11-14 14:28:04 +0100
commitad757805ca3c6556dd912881d5469b97b1f66171 (patch)
treea24946c1eef99ed6ddf36293a4551e1710c95533
parent2a39ac043e1bcb42111e7f442814d6f11522365b (diff)
downloadnextcloud-server-ad757805ca3c6556dd912881d5469b97b1f66171.tar.gz
nextcloud-server-ad757805ca3c6556dd912881d5469b97b1f66171.zip
Pass the exception context to the crash reporter
This should allow better reports as often the app id is passed as context. While this is not used right now, I'd like to have this for NC13 as adding it later will break the interface for existing apps Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
-rw-r--r--lib/private/Log.php2
-rw-r--r--lib/private/Support/CrashReport/Registry.php5
-rw-r--r--lib/public/Support/CrashReport/IRegistry.php3
-rw-r--r--lib/public/Support/CrashReport/IReporter.php3
-rw-r--r--tests/lib/LoggerTest.php8
5 files changed, 12 insertions, 9 deletions
diff --git a/lib/private/Log.php b/lib/private/Log.php
index 6b97a3a028e..a41c728df0d 100644
--- a/lib/private/Log.php
+++ b/lib/private/Log.php
@@ -352,7 +352,7 @@ class Log implements ILogger {
$msg .= ': ' . json_encode($data);
$this->log($level, $msg, $context);
if (!is_null($this->crashReporters)) {
- $this->crashReporters->delegateReport($exception);
+ $this->crashReporters->delegateReport($exception, $context);
}
}
diff --git a/lib/private/Support/CrashReport/Registry.php b/lib/private/Support/CrashReport/Registry.php
index bdf18b492fd..e90e82958d1 100644
--- a/lib/private/Support/CrashReport/Registry.php
+++ b/lib/private/Support/CrashReport/Registry.php
@@ -45,10 +45,11 @@ class Registry implements IRegistry {
* Delegate crash reporting to all registered reporters
*
* @param Exception|Throwable $exception
+ * @param array $context
*/
- public function delegateReport($exception) {
+ public function delegateReport($exception, array $context = []) {
foreach ($this->reporters as $reporter) {
- $reporter->report($exception);
+ $reporter->report($exception, $context);
}
}
diff --git a/lib/public/Support/CrashReport/IRegistry.php b/lib/public/Support/CrashReport/IRegistry.php
index 66c527092bb..62432c782ab 100644
--- a/lib/public/Support/CrashReport/IRegistry.php
+++ b/lib/public/Support/CrashReport/IRegistry.php
@@ -43,6 +43,7 @@ interface IRegistry {
*
* @since 13.0.0
* @param Exception|Throwable $exception
+ * @param array $context
*/
- public function delegateReport($exception);
+ public function delegateReport($exception, array $context = []);
}
diff --git a/lib/public/Support/CrashReport/IReporter.php b/lib/public/Support/CrashReport/IReporter.php
index 03c4f47e3b2..4700f275df4 100644
--- a/lib/public/Support/CrashReport/IReporter.php
+++ b/lib/public/Support/CrashReport/IReporter.php
@@ -35,6 +35,7 @@ interface IReporter {
*
* @since 13.0.0
* @param Exception|Throwable $exception
+ * @param array $context
*/
- public function report($exception);
+ public function report($exception, array $context = []);
}
diff --git a/tests/lib/LoggerTest.php b/tests/lib/LoggerTest.php
index 76f33849deb..54336da105c 100644
--- a/tests/lib/LoggerTest.php
+++ b/tests/lib/LoggerTest.php
@@ -90,7 +90,7 @@ class LoggerTest extends TestCase {
$e = new \Exception('test');
$this->registry->expects($this->once())
->method('delegateReport')
- ->with($e);
+ ->with($e, []);
$this->logger->logException($e);
@@ -109,7 +109,7 @@ class LoggerTest extends TestCase {
$e = new \Exception('test');
$this->registry->expects($this->once())
->method('delegateReport')
- ->with($e);
+ ->with($e, []);
$this->logger->logException($e);
@@ -128,7 +128,7 @@ class LoggerTest extends TestCase {
$e = new \Exception('test');
$this->registry->expects($this->once())
->method('delegateReport')
- ->with($e);
+ ->with($e, []);
$this->logger->logException($e);
@@ -147,7 +147,7 @@ class LoggerTest extends TestCase {
$e = new \Exception('test');
$this->registry->expects($this->once())
->method('delegateReport')
- ->with($e);
+ ->with($e, []);
$this->logger->logException($e);