1
0

StorageNotAvailableException.php 2.6 KB

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