1
0

TranslatedException.php 985 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php declare(strict_types=1);
  2. /**
  3. * PrivateBin
  4. *
  5. * a zero-knowledge paste bin
  6. *
  7. * @link https://github.com/PrivateBin/PrivateBin
  8. * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net)
  9. * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
  10. */
  11. namespace PrivateBin\Exception;
  12. use Exception;
  13. use PrivateBin\I18n;
  14. /**
  15. * TranslatedException
  16. *
  17. * An Exception that translates it's message.
  18. */
  19. class TranslatedException extends Exception
  20. {
  21. /**
  22. * Translating exception constructor with mandatory messageId.
  23. *
  24. * @access public
  25. * @param string|array $messageId message ID or array of message ID and parameters
  26. * @param int $code
  27. */
  28. public function __construct(string|array $messageId, int $code = 0)
  29. {
  30. $message = is_string($messageId) ? I18n::translate($messageId) : forward_static_call_array('PrivateBin\I18n::translate', $messageId);
  31. parent::__construct($message, $code);
  32. }
  33. }