StorageNotAvailableException.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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
  37. * @since 8.2.1 based on HintException
  38. */
  39. class StorageNotAvailableException extends HintException {
  40. /**
  41. * @since 8.2.0
  42. */
  43. public const STATUS_SUCCESS = 0;
  44. /**
  45. * @since 8.2.0
  46. */
  47. public const STATUS_ERROR = 1;
  48. /**
  49. * @since 8.2.0
  50. */
  51. public const STATUS_INDETERMINATE = 2;
  52. /**
  53. * @since 8.2.0
  54. */
  55. public const STATUS_INCOMPLETE_CONF = 3;
  56. /**
  57. * @since 8.2.0
  58. */
  59. public const STATUS_UNAUTHORIZED = 4;
  60. /**
  61. * @since 8.2.0
  62. */
  63. public const STATUS_TIMEOUT = 5;
  64. /**
  65. * @since 8.2.0
  66. */
  67. public const STATUS_NETWORK_ERROR = 6;
  68. /**
  69. * StorageNotAvailableException constructor.
  70. *
  71. * @param string $message
  72. * @param int $code
  73. * @param \Exception|null $previous
  74. * @since 6.0.0
  75. */
  76. public function __construct($message = '', $code = self::STATUS_ERROR, \Exception $previous = null) {
  77. $l = \OCP\Util::getL10N('core');
  78. parent::__construct($message, $l->t('Storage is temporarily not available'), $code, $previous);
  79. }
  80. /**
  81. * Get the name for a status code
  82. *
  83. * @param int $code
  84. * @return string
  85. * @since 9.0.0
  86. */
  87. public static function getStateCodeName($code) {
  88. switch ($code) {
  89. case self::STATUS_SUCCESS:
  90. return 'ok';
  91. case self::STATUS_ERROR:
  92. return 'error';
  93. case self::STATUS_INDETERMINATE:
  94. return 'indeterminate';
  95. case self::STATUS_UNAUTHORIZED:
  96. return 'unauthorized';
  97. case self::STATUS_TIMEOUT:
  98. return 'timeout';
  99. case self::STATUS_NETWORK_ERROR:
  100. return 'network error';
  101. default:
  102. return 'unknown';
  103. }
  104. }
  105. }