StorageNotAvailableException.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Björn Schießle <bjoern@schiessle.org>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Jesús Macias <jmacias@solidgear.es>
  8. * @author Lukas Reschke <lukas@statuscode.ch>
  9. * @author Morris Jobke <hey@morrisjobke.de>
  10. * @author Robin Appelman <robin@icewind.nl>
  11. * @author Robin McCorkell <robin@mccorkell.me.uk>
  12. * @author Roeland Jago Douma <roeland@famdouma.nl>
  13. * @author Vincent Petry <vincent@nextcloud.com>
  14. *
  15. * @license AGPL-3.0
  16. *
  17. * This code is free software: you can redistribute it and/or modify
  18. * it under the terms of the GNU Affero General Public License, version 3,
  19. * as published by the Free Software Foundation.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU Affero General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU Affero General Public License, version 3,
  27. * along with this program. If not, see <http://www.gnu.org/licenses/>
  28. *
  29. */
  30. // use OCP namespace for all classes that are considered public.
  31. // This means that they should be used by apps instead of the internal ownCloud classes
  32. namespace OCP\Files;
  33. use OCP\HintException;
  34. /**
  35. * Storage is temporarily not available
  36. * @since 6.0.0 - since 8.2.1 based on HintException
  37. */
  38. class StorageNotAvailableException extends HintException {
  39. public const STATUS_SUCCESS = 0;
  40. public const STATUS_ERROR = 1;
  41. public const STATUS_INDETERMINATE = 2;
  42. public const STATUS_INCOMPLETE_CONF = 3;
  43. public const STATUS_UNAUTHORIZED = 4;
  44. public const STATUS_TIMEOUT = 5;
  45. public const STATUS_NETWORK_ERROR = 6;
  46. /**
  47. * StorageNotAvailableException constructor.
  48. *
  49. * @param string $message
  50. * @param int $code
  51. * @param \Exception|null $previous
  52. * @since 6.0.0
  53. */
  54. public function __construct($message = '', $code = self::STATUS_ERROR, \Exception $previous = null) {
  55. $l = \OC::$server->getL10N('core');
  56. parent::__construct($message, $l->t('Storage is temporarily not available'), $code, $previous);
  57. }
  58. /**
  59. * Get the name for a status code
  60. *
  61. * @param int $code
  62. * @return string
  63. * @since 9.0.0
  64. */
  65. public static function getStateCodeName($code) {
  66. switch ($code) {
  67. case self::STATUS_SUCCESS:
  68. return 'ok';
  69. case self::STATUS_ERROR:
  70. return 'error';
  71. case self::STATUS_INDETERMINATE:
  72. return 'indeterminate';
  73. case self::STATUS_UNAUTHORIZED:
  74. return 'unauthorized';
  75. case self::STATUS_TIMEOUT:
  76. return 'timeout';
  77. case self::STATUS_NETWORK_ERROR:
  78. return 'network error';
  79. default:
  80. return 'unknown';
  81. }
  82. }
  83. }