refactored exceptions in controller

- added missing exception doc blocks
- introduced exception type that translates message during construction
- catch explicit exception types where possible
This commit is contained in:
El RIDO
2025-11-17 17:28:13 +01:00
parent fdd2c67b49
commit 3e6f1733f9
10 changed files with 105 additions and 53 deletions
+4 -5
View File
@@ -12,11 +12,10 @@
namespace PrivateBin\Persistence;
use Exception;
use IPLib\Factory;
use IPLib\ParseStringFlag;
use PrivateBin\Configuration;
use PrivateBin\I18n;
use PrivateBin\TranslatedException;
/**
* TrafficLimiter
@@ -167,7 +166,7 @@ class TrafficLimiter extends AbstractPersistence
*
* @access public
* @static
* @throws Exception
* @throws TranslatedException
* @return true
*/
public static function canPass()
@@ -181,7 +180,7 @@ class TrafficLimiter extends AbstractPersistence
return true;
}
}
throw new Exception(I18n::_('Your IP is not authorized to create documents.'));
throw new TranslatedException('Your IP is not authorized to create documents.');
}
// disable limits if set to less then 1
@@ -210,7 +209,7 @@ class TrafficLimiter extends AbstractPersistence
}
return true;
}
throw new Exception(I18n::_(
throw new TranslatedException(array(
'Please wait %d seconds between each post.',
self::$_limit
));