hintexception.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bart Visscher <bartv@thisnet.nl>
  6. * @author Lukas Reschke <lukas@statuscode.ch>
  7. * @author Michael Gapczynski <GapczynskiM@gmail.com>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Thomas Müller <thomas.mueller@tmit.eu>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. namespace OC;
  27. class HintException extends \Exception {
  28. private $hint;
  29. public function __construct($message, $hint = '', $code = 0, \Exception $previous = null) {
  30. $this->hint = $hint;
  31. parent::__construct($message, $code, $previous);
  32. }
  33. public function __toString() {
  34. return __CLASS__ . ": [{$this->code}]: {$this->message} ({$this->hint})\n";
  35. }
  36. public function getHint() {
  37. if (empty($this->hint)) {
  38. return $this->message;
  39. }
  40. return $this->hint;
  41. }
  42. }