LockNotAcquiredException.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Owen Winkler <a_github@midnightcircus.com>
  8. * @author Robin Appelman <robin@icewind.nl>
  9. * @author Roeland Jago Douma <roeland@famdouma.nl>
  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. // use OCP namespace for all classes that are considered public.
  27. // This means that they should be used by apps instead of the internal ownCloud classes
  28. namespace OCP\Files;
  29. /**
  30. * Exception for a file that is locked
  31. * @since 7.0.0
  32. */
  33. class LockNotAcquiredException extends \Exception {
  34. /** @var string $path The path that could not be locked */
  35. public $path;
  36. /** @var integer $lockType The type of the lock that was attempted */
  37. public $lockType;
  38. /**
  39. * @since 7.0.0
  40. */
  41. public function __construct($path, $lockType, $code = 0, \Exception $previous = null) {
  42. $message = \OC::$server->getL10N('core')->t('Could not obtain lock type %d on "%s".', [$lockType, $path]);
  43. parent::__construct($message, $code, $previous);
  44. }
  45. /**
  46. * custom string representation of object
  47. *
  48. * @return string
  49. * @since 7.0.0
  50. */
  51. public function __toString() {
  52. return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
  53. }
  54. }