Explorar o código

expose permission exceptions to the API

El RIDO %!s(int64=6) %!d(string=hai) anos
pai
achega
7794915172
Modificáronse 1 ficheiros con 14 adicións e 9 borrados
  1. 14 9
      lib/Controller.php

+ 14 - 9
lib/Controller.php

@@ -196,15 +196,20 @@ class Controller
      */
     private function _create()
     {
-        // Ensure last paste from visitors IP address was more than configured amount of seconds ago.
-        TrafficLimiter::setConfiguration($this->_conf);
-        if (!TrafficLimiter::canPass()) {
-            $this->_return_message(
-                1, I18n::_(
-                    'Please wait %d seconds between each post.',
-                    $this->_conf->getKey('limit', 'traffic')
-                )
-            );
+        try {
+            // Ensure last paste from visitors IP address was more than configured amount of seconds ago.
+            TrafficLimiter::setConfiguration($this->_conf);
+            if (!TrafficLimiter::canPass()) {
+                $this->_return_message(
+                    1, I18n::_(
+                        'Please wait %d seconds between each post.',
+                        $this->_conf->getKey('limit', 'traffic')
+                    )
+                );
+                return;
+            }
+        } catch (Exception $e) {
+            $this->_return_message(1, I18n::_($e->getMessage()));
             return;
         }