LockedException.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016, ownCloud, Inc.
  5. *
  6. * @author Lukas Reschke <lukas@statuscode.ch>
  7. * @author Morris Jobke <hey@morrisjobke.de>
  8. * @author Robin Appelman <robin@icewind.nl>
  9. * @author Vincent Petry <pvince81@owncloud.com>
  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 OCP\Lock;
  27. /**
  28. * Class LockedException
  29. *
  30. * @package OCP\Lock
  31. * @since 8.1.0
  32. */
  33. class LockedException extends \Exception {
  34. /**
  35. * Locked path
  36. *
  37. * @var string
  38. */
  39. private $path;
  40. /**
  41. * LockedException constructor.
  42. *
  43. * @param string $path locked path
  44. * @param \Exception|null $previous previous exception for cascading
  45. * @param string $existingLock since 14.0.0
  46. * @since 8.1.0
  47. */
  48. public function __construct(string $path, \Exception $previous = null, string $existingLock = null) {
  49. $message = '"' . $path . '" is locked';
  50. if ($existingLock) {
  51. $message .= ', existing lock on file: ' . $existingLock;
  52. }
  53. parent::__construct($message, 0, $previous);
  54. $this->path = $path;
  55. }
  56. /**
  57. * @return string
  58. * @since 8.1.0
  59. */
  60. public function getPath(): string {
  61. return $this->path;
  62. }
  63. }