1
0

StorageNotAvailableException.php 2.7 KB

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