diff --git a/apps/dav/lib/connector/sabre/objecttree.php b/apps/dav/lib/connector/sabre/objecttree.php
index 505a42d4746d287ef50b0c6cfaac2c00aaef387d..f38dfe679c75813a0fb78fdb4f0386d5c085d90a 100644
--- a/apps/dav/lib/connector/sabre/objecttree.php
+++ b/apps/dav/lib/connector/sabre/objecttree.php
@@ -102,9 +102,11 @@ class ObjectTree extends \Sabre\DAV\Tree {
 	 * Returns the INode object for the requested path
 	 *
 	 * @param string $path
-	 * @throws \Sabre\DAV\Exception\ServiceUnavailable
-	 * @throws \Sabre\DAV\Exception\NotFound
 	 * @return \Sabre\DAV\INode
+	 * @throws InvalidPath
+	 * @throws \Sabre\DAV\Exception\Locked
+	 * @throws \Sabre\DAV\Exception\NotFound
+	 * @throws \Sabre\DAV\Exception\ServiceUnavailable
 	 */
 	public function getNodeForPath($path) {
 		if (!$this->fileView) {
diff --git a/apps/dav/lib/connector/sabre/serverfactory.php b/apps/dav/lib/connector/sabre/serverfactory.php
index 8158db3e92af0f4b86e753734ceefea8fa190d37..cab7a85d19fd94310fd62207b892bb15731c4053 100644
--- a/apps/dav/lib/connector/sabre/serverfactory.php
+++ b/apps/dav/lib/connector/sabre/serverfactory.php
@@ -26,6 +26,7 @@
 
 namespace OCA\DAV\Connector\Sabre;
 
+use OCA\DAV\Files\BrowserErrorPagePlugin;
 use OCP\Files\Mount\IMountManager;
 use OCP\IConfig;
 use OCP\IDBConnection;
@@ -115,6 +116,10 @@ class ServerFactory {
 			$server->addPlugin(new \OCA\DAV\Connector\Sabre\FakeLockerPlugin());
 		}
 
+		if (BrowserErrorPagePlugin::isBrowserRequest($this->request)) {
+			$server->addPlugin(new BrowserErrorPagePlugin());
+		}
+
 		// wait with registering these until auth is handled and the filesystem is setup
 		$server->on('beforeMethod', function () use ($server, $objectTree, $viewCallBack) {
 			// ensure the skeleton is copied
diff --git a/apps/dav/lib/files/browsererrorpageplugin.php b/apps/dav/lib/files/browsererrorpageplugin.php
new file mode 100644
index 0000000000000000000000000000000000000000..37a4166efef56bf0cc1188e816e5425627b562d0
--- /dev/null
+++ b/apps/dav/lib/files/browsererrorpageplugin.php
@@ -0,0 +1,116 @@
+<?php
+/**
+ * @author Thomas Müller <thomas.mueller@tmit.eu>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCA\DAV\Files;
+
+use OC\AppFramework\Http\Request;
+use OC_Template;
+use OCP\IRequest;
+use Sabre\DAV\Exception;
+use Sabre\DAV\Server;
+use Sabre\DAV\ServerPlugin;
+
+class BrowserErrorPagePlugin extends ServerPlugin {
+
+	/** @var Server */
+	private $server;
+
+	/**
+	 * This initializes the plugin.
+	 *
+	 * This function is called by Sabre\DAV\Server, after
+	 * addPlugin is called.
+	 *
+	 * This method should set up the required event subscriptions.
+	 *
+	 * @param Server $server
+	 * @return void
+	 */
+	function initialize(Server $server) {
+		$this->server = $server;
+		$server->on('exception', array($this, 'logException'), 1000);
+	}
+
+	/**
+	 * @param IRequest $request
+	 * @return bool
+	 */
+	public static function isBrowserRequest(IRequest $request) {
+		if ($request->getMethod() !== 'GET') {
+			return false;
+		}
+		return $request->isUserAgent([
+			Request::USER_AGENT_IE,
+			Request::USER_AGENT_MS_EDGE,
+			Request::USER_AGENT_CHROME,
+			Request::USER_AGENT_FIREFOX,
+			Request::USER_AGENT_SAFARI,
+		]);
+	}
+
+	/**
+	 * @param \Exception $ex
+	 */
+	public function logException(\Exception $ex) {
+		if ($ex instanceof Exception) {
+			$httpCode = $ex->getHTTPCode();
+			$headers = $ex->getHTTPHeaders($this->server);
+		} else {
+			$httpCode = 500;
+			$headers = [];
+		}
+		$this->server->httpResponse->addHeaders($headers);
+		$this->server->httpResponse->setStatus($httpCode);
+		$body = $this->generateBody($ex);
+		$this->server->httpResponse->setBody($body);
+		$this->sendResponse();
+	}
+
+	/**
+	 * @codeCoverageIgnore
+	 * @param \Exception $ex
+	 * @param int $httpCode
+	 * @return bool|string
+	 */
+	public function generateBody(\Exception $exception) {
+		$request = \OC::$server->getRequest();
+		$content = new OC_Template('dav', 'exception', 'guest');
+		$content->assign('title', $this->server->httpResponse->getStatusText());
+		$content->assign('message', $exception->getMessage());
+		$content->assign('errorClass', get_class($exception));
+		$content->assign('errorMsg', $exception->getMessage());
+		$content->assign('errorCode', $exception->getCode());
+		$content->assign('file', $exception->getFile());
+		$content->assign('line', $exception->getLine());
+		$content->assign('trace', $exception->getTraceAsString());
+		$content->assign('debugMode', \OC::$server->getSystemConfig()->getValue('debug', false));
+		$content->assign('remoteAddr', $request->getRemoteAddress());
+		$content->assign('requestID', $request->getId());
+		return $content->fetchPage();
+	}
+
+	/*
+	 * @codeCoverageIgnore
+	 */
+	public function sendResponse() {
+		$this->server->sapi->sendResponse($this->server->httpResponse);
+	}
+}
diff --git a/apps/dav/lib/server.php b/apps/dav/lib/server.php
index e74292282a7136443c044b8fea64a1ba93f2d2a4..5336c82dfb80cb7a170ca15f9925ba6c63f646b5 100644
--- a/apps/dav/lib/server.php
+++ b/apps/dav/lib/server.php
@@ -30,6 +30,7 @@ use OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin;
 use OCA\DAV\Connector\Sabre\DavAclPlugin;
 use OCA\DAV\Connector\Sabre\DummyGetResponsePlugin;
 use OCA\DAV\Connector\Sabre\FilesPlugin;
+use OCA\DAV\Files\BrowserErrorPagePlugin;
 use OCA\DAV\Files\CustomPropertiesBackend;
 use OCP\IRequest;
 use OCP\SabrePluginEvent;
@@ -119,6 +120,10 @@ class Server {
 			$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\FakeLockerPlugin());
 		}
 
+		if (BrowserErrorPagePlugin::isBrowserRequest($request)) {
+			$this->server->addPlugin(new BrowserErrorPagePlugin());
+		}
+
 		// wait with registering these until auth is handled and the filesystem is setup
 		$this->server->on('beforeMethod', function () {
 			// custom properties plugin must be the last one
diff --git a/apps/dav/templates/exception.php b/apps/dav/templates/exception.php
new file mode 100644
index 0000000000000000000000000000000000000000..01c4eea4b5adaded4e8d65ad1ce03497d9b18e8e
--- /dev/null
+++ b/apps/dav/templates/exception.php
@@ -0,0 +1,30 @@
+<?php
+	/** @var array $_ */
+	/** @var OC_L10N $l */
+
+style('core', ['styles', 'header']);
+?>
+<span class="error error-wide">
+	<h2><strong><?php p($_['title']) ?></strong></h2>
+		<p><?php p($_['message']) ?></p>
+	<br>
+
+	<h2><strong><?php p($l->t('Technical details')) ?></strong></h2>
+	<ul>
+		<li><?php p($l->t('Remote Address: %s', $_['remoteAddr'])) ?></li>
+		<li><?php p($l->t('Request ID: %s', $_['requestID'])) ?></li>
+		<?php if($_['debugMode']): ?>
+			<li><?php p($l->t('Type: %s', $_['errorClass'])) ?></li>
+			<li><?php p($l->t('Code: %s', $_['errorCode'])) ?></li>
+			<li><?php p($l->t('Message: %s', $_['errorMsg'])) ?></li>
+			<li><?php p($l->t('File: %s', $_['file'])) ?></li>
+			<li><?php p($l->t('Line: %s', $_['line'])) ?></li>
+		<?php endif; ?>
+	</ul>
+
+	<?php if($_['debugMode']): ?>
+		<br />
+		<h2><strong><?php p($l->t('Trace')) ?></strong></h2>
+		<pre><?php p($_['trace']) ?></pre>
+	<?php endif; ?>
+</span>
diff --git a/apps/dav/tests/unit/dav/browsererrorpageplugintest.php b/apps/dav/tests/unit/dav/browsererrorpageplugintest.php
new file mode 100644
index 0000000000000000000000000000000000000000..aeae0e1b1527b0b860d6be2153bb9534f142e2bc
--- /dev/null
+++ b/apps/dav/tests/unit/dav/browsererrorpageplugintest.php
@@ -0,0 +1,57 @@
+<?php
+/**
+ * @author Thomas Müller <thomas.mueller@tmit.eu>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+namespace OCA\DAV\Tests\Unit\DAV;
+
+use OCA\DAV\Files\BrowserErrorPagePlugin;
+use PHPUnit_Framework_MockObject_MockObject;
+use Sabre\DAV\Exception\NotFound;
+
+class BrowserErrorPagePluginTest extends \Test\TestCase {
+
+	/**
+	 * @dataProvider providesExceptions
+	 * @param $expectedCode
+	 * @param $exception
+	 */
+	public function test($expectedCode, $exception) {
+		/** @var BrowserErrorPagePlugin | PHPUnit_Framework_MockObject_MockObject $plugin */
+		$plugin = $this->getMockBuilder('OCA\DAV\Files\BrowserErrorPagePlugin')->setMethods(['sendResponse', 'generateBody'])->getMock();
+		$plugin->expects($this->once())->method('generateBody')->willReturn(':boom:');
+		$plugin->expects($this->once())->method('sendResponse');
+		/** @var \Sabre\DAV\Server | PHPUnit_Framework_MockObject_MockObject $server */
+		$server = $this->getMockBuilder('Sabre\DAV\Server')->disableOriginalConstructor()->getMock();
+		$server->expects($this->once())->method('on');
+		$httpResponse = $this->getMockBuilder('Sabre\HTTP\Response')->disableOriginalConstructor()->getMock();
+		$httpResponse->expects($this->once())->method('addHeaders');
+		$httpResponse->expects($this->once())->method('setStatus')->with($expectedCode);
+		$httpResponse->expects($this->once())->method('setBody')->with(':boom:');
+		$server->httpResponse = $httpResponse;
+		$plugin->initialize($server);
+		$plugin->logException($exception);
+	}
+
+	public function providesExceptions() {
+		return [
+			[ 404, new NotFound()],
+			[ 500, new \RuntimeException()],
+		];
+	}
+}
diff --git a/lib/private/appframework/http/request.php b/lib/private/appframework/http/request.php
index f4cbb6384ba090c2b5c1069c656d95ce783752e4..c8525d1d14163c068a6d179b75886dccfd842e91 100644
--- a/lib/private/appframework/http/request.php
+++ b/lib/private/appframework/http/request.php
@@ -56,6 +56,14 @@ class Request implements \ArrayAccess, \Countable, IRequest {
 
 	const USER_AGENT_IE = '/(MSIE)|(Trident)/';
 	const USER_AGENT_IE_8 = '/MSIE 8.0/';
+	// Microsoft Edge User Agent from https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx
+	const USER_AGENT_MS_EDGE = '/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\) Chrome\/[0-9.]+ (Mobile Safari|Safari)\/[0-9.]+ Edge\/[0-9.]+$/';
+	// Firefox User Agent from https://developer.mozilla.org/en-US/docs/Web/HTTP/Gecko_user_agent_string_reference
+	const USER_AGENT_FIREFOX = '/^Mozilla\/5\.0 \([^)]+\) Gecko\/[0-9.]+ Firefox\/[0-9.]+$/';
+	// Chrome User Agent from https://developer.chrome.com/multidevice/user-agent
+	const USER_AGENT_CHROME = '/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\) Chrome\/[0-9.]+ (Mobile Safari|Safari)\/[0-9.]+$/';
+	// Safari User Agent from http://www.useragentstring.com/pages/Safari/
+	const USER_AGENT_SAFARI = '/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\) Version\/[0-9.]+ Safari\/[0-9.A-Z]+$/';
 	// Android Chrome user agent: https://developers.google.com/chrome/mobile/docs/user-agent
 	const USER_AGENT_ANDROID_MOBILE_CHROME = '#Android.*Chrome/[.0-9]*#';
 	const USER_AGENT_FREEBOX = '#^Mozilla/5\.0$#';
diff --git a/lib/private/template.php b/lib/private/template.php
index bc706e29344740aafe6cf5c7fcd7b88453f5eaaa..2653ae6086ad2780df5453bdaf112ba20dc067b3 100644
--- a/lib/private/template.php
+++ b/lib/private/template.php
@@ -333,7 +333,7 @@ class OC_Template extends \OC\Template\Base {
 	 * print error page using Exception details
 	 * @param Exception $exception
 	 */
-	public static function printExceptionErrorPage($exception) {
+	public static function printExceptionErrorPage($exception, $fetchPage = false) {
 		try {
 			$request = \OC::$server->getRequest();
 			$content = new \OC_Template('', 'exception', 'error', false);
@@ -346,6 +346,9 @@ class OC_Template extends \OC\Template\Base {
 			$content->assign('debugMode', \OC::$server->getSystemConfig()->getValue('debug', false));
 			$content->assign('remoteAddr', $request->getRemoteAddress());
 			$content->assign('requestID', $request->getId());
+			if ($fetchPage) {
+				return $content->fetchPage();
+			}
 			$content->printPage();
 		} catch (\Exception $e) {
 			$logger = \OC::$server->getLogger();