Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
4531b4a8
Unverified
Commit
4531b4a8
authored
8 years ago
by
Bjoern Schiessle
Browse files
Options
Downloads
Patches
Plain Diff
only execute code if exception was thrown by the corresponding controller
Signed-off-by:
Bjoern Schiessle
<
bjoern@schiessle.org
>
parent
faf836b0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/federation/lib/Middleware/AddServerMiddleware.php
+4
-0
4 additions, 0 deletions
apps/federation/lib/Middleware/AddServerMiddleware.php
apps/federation/tests/Middleware/AddServerMiddlewareTest.php
+3
-3
3 additions, 3 deletions
apps/federation/tests/Middleware/AddServerMiddlewareTest.php
with
7 additions
and
3 deletions
apps/federation/lib/Middleware/AddServerMiddleware.php
+
4
−
0
View file @
4531b4a8
...
...
@@ -25,6 +25,7 @@
namespace
OCA\Federation\Middleware
;
use
OC\HintException
;
use
OCA\Federation\Controller\SettingsController
;
use
OCP\AppFramework\Http
;
use
OCP\AppFramework\Http\JSONResponse
;
use
OCP\AppFramework\Middleware
;
...
...
@@ -57,6 +58,9 @@ class AddServerMiddleware extends Middleware {
* @return JSONResponse
*/
public
function
afterException
(
$controller
,
$methodName
,
\Exception
$exception
)
{
if
((
$controller
instanceof
SettingsController
)
===
false
)
{
throw
$exception
;
}
$this
->
logger
->
error
(
$exception
->
getMessage
(),
[
'app'
=>
$this
->
appName
]);
if
(
$exception
instanceof
HintException
)
{
$message
=
$exception
->
getHint
();
...
...
This diff is collapsed.
Click to expand it.
apps/federation/tests/Middleware/AddServerMiddlewareTest.php
+
3
−
3
View file @
4531b4a8
...
...
@@ -26,8 +26,8 @@ namespace OCA\Federation\Tests\Middleware;
use
OC\HintException
;
use
OCA\Federation\Controller\SettingsController
;
use
OCA\Federation\Middleware\AddServerMiddleware
;
use
OCP\AppFramework\Controller
;
use
OCP\AppFramework\Http
;
use
OCP\IL10N
;
use
OCP\ILogger
;
...
...
@@ -44,7 +44,7 @@ class AddServerMiddlewareTest extends TestCase {
/** @var AddServerMiddleware */
private
$middleware
;
/** @var \PHPUnit_Framework_MockObject_MockObject | Controller */
/** @var \PHPUnit_Framework_MockObject_MockObject |
Settings
Controller */
private
$controller
;
public
function
setUp
()
{
...
...
@@ -52,7 +52,7 @@ class AddServerMiddlewareTest extends TestCase {
$this
->
logger
=
$this
->
getMockBuilder
(
ILogger
::
class
)
->
getMock
();
$this
->
l10n
=
$this
->
getMockBuilder
(
IL10N
::
class
)
->
getMock
();
$this
->
controller
=
$this
->
getMockBuilder
(
Controller
::
class
)
$this
->
controller
=
$this
->
getMockBuilder
(
Settings
Controller
::
class
)
->
disableOriginalConstructor
()
->
getMock
();
$this
->
middleware
=
new
AddServerMiddleware
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment