Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
5dc7eebc
Commit
5dc7eebc
authored
9 years ago
by
Thomas Müller
Browse files
Options
Downloads
Patches
Plain Diff
Adding request specific exception handling - now with WebDAV responses - refs #17192
parent
3f3c6039
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
remote.php
+33
-7
33 additions, 7 deletions
remote.php
with
33 additions
and
7 deletions
remote.php
+
33
−
7
View file @
5dc7eebc
...
...
@@ -25,6 +25,38 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
use
OC\Connector\Sabre\ExceptionLoggerPlugin
;
use
Sabre\DAV\Exception\ServiceUnavailable
;
use
Sabre\DAV\Server
;
/**
* @param Exception $e
*/
function
handleException
(
Exception
$e
)
{
$request
=
\OC
::
$server
->
getRequest
();
// in case the request content type is text/xml - we assume it's a WebDAV request
if
(
$request
->
getHeader
(
'Content-Type'
)
===
'text/xml'
)
{
// fire up a simple server to properly process the exception
$server
=
new
Server
();
$server
->
addPlugin
(
new
ExceptionLoggerPlugin
(
'webdav'
,
\OC
::
$server
->
getLogger
()));
$server
->
on
(
'beforeMethod'
,
function
()
use
(
$e
)
{
$class
=
get_class
(
$e
);
$msg
=
$e
->
getMessage
();
throw
new
ServiceUnavailable
(
"
$class
:
$msg
"
);
});
$server
->
exec
();
}
else
{
if
(
$e
instanceof
\OC\ServiceUnavailableException
)
{
OC_Response
::
setStatus
(
OC_Response
::
STATUS_SERVICE_UNAVAILABLE
);
}
else
{
OC_Response
::
setStatus
(
OC_Response
::
STATUS_INTERNAL_SERVER_ERROR
);
}
\OCP\Util
::
writeLog
(
'remote'
,
$e
->
getMessage
(),
\OCP\Util
::
FATAL
);
OC_Template
::
printExceptionErrorPage
(
$e
);
}
}
try
{
require_once
'lib/base.php'
;
...
...
@@ -82,12 +114,6 @@ try {
$baseuri
=
OC
::
$WEBROOT
.
'/remote.php/'
.
$service
.
'/'
;
require_once
$file
;
}
catch
(
\OC\ServiceUnavailableException
$ex
)
{
OC_Response
::
setStatus
(
OC_Response
::
STATUS_SERVICE_UNAVAILABLE
);
\OCP\Util
::
writeLog
(
'remote'
,
$ex
->
getMessage
(),
\OCP\Util
::
FATAL
);
OC_Template
::
printExceptionErrorPage
(
$ex
);
}
catch
(
Exception
$ex
)
{
OC_Response
::
setStatus
(
OC_Response
::
STATUS_INTERNAL_SERVER_ERROR
);
\OCP\Util
::
writeLog
(
'remote'
,
$ex
->
getMessage
(),
\OCP\Util
::
FATAL
);
OC_Template
::
printExceptionErrorPage
(
$ex
);
handleException
(
$ex
);
}
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