StorageNotAvailableException.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 Morris Jobke <hey@morrisjobke.de>
  8. * @author Robin Appelman <robin@icewind.nl>
  9. * @author Robin McCorkell <robin@mccorkell.me.uk>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. /**
  27. * Public interface of ownCloud for apps to use.
  28. * Files/AlreadyExistsException class
  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 OC\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. const STATUS_SUCCESS = 0;
  40. const STATUS_ERROR = 1;
  41. const STATUS_INDETERMINATE = 2;
  42. const STATUS_INCOMPLETE_CONF = 3;
  43. const STATUS_UNAUTHORIZED = 4;
  44. const STATUS_TIMEOUT = 5;
  45. const STATUS_NETWORK_ERROR = 6;
  46. /**
  47. * StorageNotAvailableException constructor.
  48. *
  49. * @param string $message
  50. * @param int $code
  51. * @param \Exception $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. }