LockedException.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 Roeland Jago Douma <roeland@famdouma.nl>
  10. * @author Vincent Petry <pvince81@owncloud.com>
  11. *
  12. * @license AGPL-3.0
  13. *
  14. * This code is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License, version 3,
  16. * as published by the Free Software Foundation.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License, version 3,
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>
  25. *
  26. */
  27. namespace OCP\Lock;
  28. /**
  29. * Class LockedException
  30. *
  31. * @package OCP\Lock
  32. * @since 8.1.0
  33. */
  34. class LockedException extends \Exception {
  35. /**
  36. * Locked path
  37. *
  38. * @var string
  39. */
  40. private $path;
  41. /**
  42. * LockedException constructor.
  43. *
  44. * @param string $path locked path
  45. * @param \Exception|null $previous previous exception for cascading
  46. * @param string $existingLock since 14.0.0
  47. * @since 8.1.0
  48. */
  49. public function __construct(string $path, \Exception $previous = null, string $existingLock = null) {
  50. $message = '"' . $path . '" is locked';
  51. if ($existingLock) {
  52. $message .= ', existing lock on file: ' . $existingLock;
  53. }
  54. parent::__construct($message, 0, $previous);
  55. $this->path = $path;
  56. }
  57. /**
  58. * @return string
  59. * @since 8.1.0
  60. */
  61. public function getPath(): string {
  62. return $this->path;
  63. }
  64. }