summaryrefslogtreecommitdiffstats
path: root/apps/provisioning_api
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/provisioning_api
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/provisioning_api')
-rw-r--r--apps/provisioning_api/lib/Controller/UsersController.php12
-rw-r--r--apps/provisioning_api/tests/Controller/UsersControllerTest.php11
2 files changed, 18 insertions, 5 deletions
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php
index ffae68d5a95..9098797f1ac 100644
--- a/apps/provisioning_api/lib/Controller/UsersController.php
+++ b/apps/provisioning_api/lib/Controller/UsersController.php
@@ -197,7 +197,11 @@ class UsersController extends OCSController {
}
return new DataResponse();
} catch (\Exception $e) {
- $this->logger->error('Failed addUser attempt with exception: '.$e->getMessage(), ['app' => 'ocs_api']);
+ $this->logger->logException($e, [
+ 'message' => 'Failed addUser attempt with exception.',
+ 'level' => \OCP\Util::ERROR,
+ 'app' => 'ocs_api',
+ ]);
throw new OCSException('Bad request', 101);
}
}
@@ -826,7 +830,11 @@ class UsersController extends OCSController {
$emailTemplate = $this->newUserMailHelper->generateTemplate($targetUser, false);
$this->newUserMailHelper->sendMail($targetUser, $emailTemplate);
} catch(\Exception $e) {
- $this->logger->error("Can't send new user mail to $email: " . $e->getMessage(), array('app' => 'settings'));
+ $this->logger->logException($e, [
+ 'message' => "Can't send new user mail to $email",
+ 'level' => \OCP\Util::ERROR,
+ 'app' => 'settings',
+ ]);
throw new OCSException('Sending email failed', 102);
}
diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
index ef47583e9df..c2ad36c455c 100644
--- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
@@ -414,6 +414,7 @@ class UsersControllerTest extends TestCase {
* @expectedExceptionMessage Bad request
*/
public function testAddUserUnsuccessful() {
+ $exception = new Exception('User backend not found.');
$this->userManager
->expects($this->once())
->method('userExists')
@@ -423,11 +424,15 @@ class UsersControllerTest extends TestCase {
->expects($this->once())
->method('createUser')
->with('NewUser', 'PasswordOfTheNewUser')
- ->will($this->throwException(new Exception('User backend not found.')));
+ ->will($this->throwException($exception));
$this->logger
->expects($this->once())
- ->method('error')
- ->with('Failed addUser attempt with exception: User backend not found.', ['app' => 'ocs_api']);
+ ->method('logException')
+ ->with($exception, [
+ 'message' => 'Failed addUser attempt with exception.',
+ 'level' => \OCP\Util::ERROR,
+ 'app' => 'ocs_api',
+ ]);
$loggedInUser = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();