LockNotAcquiredException.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. // use OCP namespace for all classes that are considered public.
  8. // This means that they should be used by apps instead of the internal Nextcloud classes
  9. namespace OCP\Files;
  10. /**
  11. * Exception for a file that is locked
  12. * @since 7.0.0
  13. */
  14. class LockNotAcquiredException extends \Exception {
  15. /** @var string $path The path that could not be locked */
  16. public $path;
  17. /** @var integer $lockType The type of the lock that was attempted */
  18. public $lockType;
  19. /**
  20. * @since 7.0.0
  21. */
  22. public function __construct($path, $lockType, $code = 0, ?\Exception $previous = null) {
  23. $message = \OCP\Util::getL10N('core')->t('Could not obtain lock type %d on "%s".', [$lockType, $path]);
  24. parent::__construct($message, $code, $previous);
  25. }
  26. /**
  27. * custom string representation of object
  28. *
  29. * @since 7.0.0
  30. */
  31. public function __toString(): string {
  32. return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
  33. }
  34. }