summaryrefslogtreecommitdiffstats
path: root/apps/federatedfilesharing/lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-01-17 15:21:56 +0100
committerMorris Jobke <hey@morrisjobke.de>2018-01-23 10:57:21 +0100
commit2a38605545e26ce68a37e5ebb877fd9c9875a37d (patch)
treea149433f3fdeae3b4615061b495e4c523328a9a6 /apps/federatedfilesharing/lib
parent520f2fd6ea3661d5d49517c7265dd8d7515036ac (diff)
downloadnextcloud-server-2a38605545e26ce68a37e5ebb877fd9c9875a37d.tar.gz
nextcloud-server-2a38605545e26ce68a37e5ebb877fd9c9875a37d.zip
Properly log the full exception instead of only the message
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'apps/federatedfilesharing/lib')
-rw-r--r--apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php44
-rw-r--r--apps/federatedfilesharing/lib/Controller/RequestHandlerController.php6
-rw-r--r--apps/federatedfilesharing/lib/FederatedShareProvider.php6
3 files changed, 34 insertions, 22 deletions
diff --git a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
index 19f98b264e6..a54a3aa69a0 100644
--- a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
+++ b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
@@ -164,6 +164,10 @@ class MountPublicLinkController extends Controller {
try {
$this->federatedShareProvider->create($share);
} catch (\Exception $e) {
+ \OC::$server->getLogger()->logException($e, [
+ 'level' => \OCP\Util::WARN,
+ 'app' => 'federatedfilesharing',
+ ]);
return new JSONResponse(['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST);
}
@@ -286,18 +290,18 @@ class MountPublicLinkController extends Controller {
$storage->checkStorageAvailability();
} catch (StorageInvalidException $e) {
// note: checkStorageAvailability will already remove the invalid share
- Util::writeLog(
- 'federatedfilesharing',
- 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(),
- Util::DEBUG
- );
+ \OC::$server->getLogger()->logException($e, [
+ 'message' => 'Invalid remote storage.',
+ 'level' => \OCP\Util::DEBUG,
+ 'app' => 'federatedfilesharing'
+ ]);
return new JSONResponse(['message' => $this->l->t('Could not authenticate to remote share, password might be wrong')], Http::STATUS_BAD_REQUEST);
} catch (\Exception $e) {
- Util::writeLog(
- 'federatedfilesharing',
- 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(),
- Util::DEBUG
- );
+ \OC::$server->getLogger()->logException($e, [
+ 'message' => 'Invalid remote storage.',
+ 'level' => \OCP\Util::DEBUG,
+ 'app' => 'federatedfilesharing'
+ ]);
$externalManager->removeShare($mount->getMountPoint());
return new JSONResponse(['message' => $this->l->t('Storage not valid')], Http::STATUS_BAD_REQUEST);
}
@@ -312,18 +316,18 @@ class MountPublicLinkController extends Controller {
]
);
} catch (StorageInvalidException $e) {
- Util::writeLog(
- 'federatedfilesharing',
- 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(),
- Util::DEBUG
- );
+ \OC::$server->getLogger()->logException($e, [
+ 'message' => 'Invalid remote storage.',
+ 'level' => \OCP\Util::DEBUG,
+ 'app' => 'federatedfilesharing'
+ ]);
return new JSONResponse(['message' => $this->l->t('Storage not valid')], Http::STATUS_BAD_REQUEST);
} catch (\Exception $e) {
- Util::writeLog(
- 'federatedfilesharing',
- 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(),
- Util::DEBUG
- );
+ \OC::$server->getLogger()->logException($e, [
+ 'message' => 'Invalid remote storage.',
+ 'level' => \OCP\Util::DEBUG,
+ 'app' => 'federatedfilesharing'
+ ]);
return new JSONResponse(['message' => $this->l->t('Couldn\'t add remote share')], Http::STATUS_BAD_REQUEST);
}
} else {
diff --git a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
index a74342f1182..bc81db50b28 100644
--- a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
+++ b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
@@ -209,7 +209,11 @@ class RequestHandlerController extends OCSController {
return new Http\DataResponse();
} catch (\Exception $e) {
- \OCP\Util::writeLog('files_sharing', 'server can not add remote share, ' . $e->getMessage(), \OCP\Util::ERROR);
+ \OC::$server->getLogger()->logException($e, [
+ 'message' => 'Server can not add remote share.',
+ 'level' => \OCP\Util::ERROR,
+ 'app' => 'files_sharing'
+ ]);
throw new OCSException('internal server error, was not able to add share from ' . $remote, 500);
}
}
diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php
index 27606c5fdec..1025c3c4ae7 100644
--- a/apps/federatedfilesharing/lib/FederatedShareProvider.php
+++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php
@@ -264,7 +264,11 @@ class FederatedShareProvider implements IShareProvider {
$failure = true;
}
} catch (\Exception $e) {
- $this->logger->error('Failed to notify remote server of federated share, removing share (' . $e->getMessage() . ')');
+ $this->logger->logException($e, [
+ 'message' => 'Failed to notify remote server of federated share, removing share.',
+ 'level' => \OCP\Util::ERROR,
+ 'app' => 'federatedfilesharing',
+ ]);
$failure = true;
}