LockNotAcquiredException.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Morris Jobke <hey@morrisjobke.de>
  6. * @author Owen Winkler <a_github@midnightcircus.com>
  7. * @author Robin Appelman <robin@icewind.nl>
  8. *
  9. * @license AGPL-3.0
  10. *
  11. * This code is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License, version 3,
  13. * as published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License, version 3,
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>
  22. *
  23. */
  24. /**
  25. * Public interface of ownCloud for apps to use.
  26. * Files/LockNotAcquiredException class
  27. */
  28. // use OCP namespace for all classes that are considered public.
  29. // This means that they should be used by apps instead of the internal ownCloud classes
  30. namespace OCP\Files;
  31. /**
  32. * Exception for a file that is locked
  33. * @since 7.0.0
  34. */
  35. class LockNotAcquiredException extends \Exception {
  36. /** @var string $path The path that could not be locked */
  37. public $path;
  38. /** @var integer $lockType The type of the lock that was attempted */
  39. public $lockType;
  40. /**
  41. * @since 7.0.0
  42. */
  43. public function __construct($path, $lockType, $code = 0, \Exception $previous = null) {
  44. $message = \OC::$server->getL10N('core')->t('Could not obtain lock type %d on "%s".', array($lockType, $path));
  45. parent::__construct($message, $code, $previous);
  46. }
  47. /**
  48. * custom string representation of object
  49. *
  50. * @return string
  51. * @since 7.0.0
  52. */
  53. public function __toString() {
  54. return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
  55. }
  56. }