Completed
Push — master ( f698aa...60a485 )
by Morris
13:44
created
apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php 1 patch
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -31,76 +31,76 @@
 block discarded – undo
31 31
 use Sabre\DAV\Exception\ServiceUnavailable;
32 32
 
33 33
 class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin {
34
-	protected $nonFatalExceptions = [
35
-		'Sabre\DAV\Exception\NotAuthenticated' => true,
36
-		// If tokenauth can throw this exception (which is basically as
37
-		// NotAuthenticated. So not fatal.
38
-		'OCA\DAV\Connector\Sabre\Exception\PasswordLoginForbidden' => true,
39
-		// the sync client uses this to find out whether files exist,
40
-		// so it is not always an error, log it as debug
41
-		'Sabre\DAV\Exception\NotFound' => true,
42
-		// this one mostly happens when the same file is uploaded at
43
-		// exactly the same time from two clients, only one client
44
-		// wins, the second one gets "Precondition failed"
45
-		'Sabre\DAV\Exception\PreconditionFailed' => true,
46
-		// forbidden can be expected when trying to upload to
47
-		// read-only folders for example
48
-		'Sabre\DAV\Exception\Forbidden' => true,
49
-		// Happens when an external storage or federated share is temporarily
50
-		// not available
51
-		'Sabre\DAV\Exception\StorageNotAvailableException' => true,
52
-	];
34
+    protected $nonFatalExceptions = [
35
+        'Sabre\DAV\Exception\NotAuthenticated' => true,
36
+        // If tokenauth can throw this exception (which is basically as
37
+        // NotAuthenticated. So not fatal.
38
+        'OCA\DAV\Connector\Sabre\Exception\PasswordLoginForbidden' => true,
39
+        // the sync client uses this to find out whether files exist,
40
+        // so it is not always an error, log it as debug
41
+        'Sabre\DAV\Exception\NotFound' => true,
42
+        // this one mostly happens when the same file is uploaded at
43
+        // exactly the same time from two clients, only one client
44
+        // wins, the second one gets "Precondition failed"
45
+        'Sabre\DAV\Exception\PreconditionFailed' => true,
46
+        // forbidden can be expected when trying to upload to
47
+        // read-only folders for example
48
+        'Sabre\DAV\Exception\Forbidden' => true,
49
+        // Happens when an external storage or federated share is temporarily
50
+        // not available
51
+        'Sabre\DAV\Exception\StorageNotAvailableException' => true,
52
+    ];
53 53
 
54
-	/** @var string */
55
-	private $appName;
54
+    /** @var string */
55
+    private $appName;
56 56
 
57
-	/** @var ILogger */
58
-	private $logger;
57
+    /** @var ILogger */
58
+    private $logger;
59 59
 
60
-	/**
61
-	 * @param string $loggerAppName app name to use when logging
62
-	 * @param ILogger $logger
63
-	 */
64
-	public function __construct($loggerAppName, $logger) {
65
-		$this->appName = $loggerAppName;
66
-		$this->logger = $logger;
67
-	}
60
+    /**
61
+     * @param string $loggerAppName app name to use when logging
62
+     * @param ILogger $logger
63
+     */
64
+    public function __construct($loggerAppName, $logger) {
65
+        $this->appName = $loggerAppName;
66
+        $this->logger = $logger;
67
+    }
68 68
 
69
-	/**
70
-	 * This initializes the plugin.
71
-	 *
72
-	 * This function is called by \Sabre\DAV\Server, after
73
-	 * addPlugin is called.
74
-	 *
75
-	 * This method should set up the required event subscriptions.
76
-	 *
77
-	 * @param \Sabre\DAV\Server $server
78
-	 * @return void
79
-	 */
80
-	public function initialize(\Sabre\DAV\Server $server) {
69
+    /**
70
+     * This initializes the plugin.
71
+     *
72
+     * This function is called by \Sabre\DAV\Server, after
73
+     * addPlugin is called.
74
+     *
75
+     * This method should set up the required event subscriptions.
76
+     *
77
+     * @param \Sabre\DAV\Server $server
78
+     * @return void
79
+     */
80
+    public function initialize(\Sabre\DAV\Server $server) {
81 81
 
82
-		$server->on('exception', array($this, 'logException'), 10);
83
-	}
82
+        $server->on('exception', array($this, 'logException'), 10);
83
+    }
84 84
 
85
-	/**
86
-	 * Log exception
87
-	 *
88
-	 */
89
-	public function logException(\Exception $ex) {
90
-		$exceptionClass = get_class($ex);
91
-		$level = \OCP\Util::FATAL;
92
-		if (isset($this->nonFatalExceptions[$exceptionClass]) ||
93
-			(
94
-				$exceptionClass === ServiceUnavailable::class &&
95
-				$ex->getMessage() === 'System in maintenance mode.'
96
-			)
97
-		) {
98
-			$level = \OCP\Util::DEBUG;
99
-		}
85
+    /**
86
+     * Log exception
87
+     *
88
+     */
89
+    public function logException(\Exception $ex) {
90
+        $exceptionClass = get_class($ex);
91
+        $level = \OCP\Util::FATAL;
92
+        if (isset($this->nonFatalExceptions[$exceptionClass]) ||
93
+            (
94
+                $exceptionClass === ServiceUnavailable::class &&
95
+                $ex->getMessage() === 'System in maintenance mode.'
96
+            )
97
+        ) {
98
+            $level = \OCP\Util::DEBUG;
99
+        }
100 100
 
101
-		$this->logger->logException($ex, [
102
-			'app' => $this->appName,
103
-			'level' => $level,
104
-		]);
105
-	}
101
+        $this->logger->logException($ex, [
102
+            'app' => $this->appName,
103
+            'level' => $level,
104
+        ]);
105
+    }
106 106
 }
Please login to merge, or discard this patch.