2014-06-30 09:46:37 -04:00
|
|
|
<?php
|
2024-05-23 03:26:56 -04:00
|
|
|
|
2014-06-30 09:46:37 -04:00
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2014-06-30 09:46:37 -04:00
|
|
|
*/
|
|
|
|
|
// use OCP namespace for all classes that are considered public.
|
2024-05-23 03:26:56 -04:00
|
|
|
// This means that they should be used by apps instead of the internal Nextcloud classes
|
2019-11-22 14:52:10 -05:00
|
|
|
|
2014-06-30 09:46:37 -04:00
|
|
|
namespace OCP\Files;
|
2020-04-09 05:48:10 -04:00
|
|
|
|
2021-06-29 19:20:33 -04:00
|
|
|
use OCP\HintException;
|
2014-06-30 09:46:37 -04:00
|
|
|
|
2014-07-01 08:35:44 -04:00
|
|
|
/**
|
|
|
|
|
* Storage is temporarily not available
|
2024-02-14 14:48:27 -05:00
|
|
|
* @since 6.0.0
|
|
|
|
|
* @since 8.2.1 based on HintException
|
2014-07-01 08:35:44 -04:00
|
|
|
*/
|
2015-11-09 04:38:39 -05:00
|
|
|
class StorageNotAvailableException extends HintException {
|
2024-02-14 14:48:27 -05:00
|
|
|
/**
|
|
|
|
|
* @since 8.2.0
|
|
|
|
|
*/
|
2020-04-10 10:54:27 -04:00
|
|
|
public const STATUS_SUCCESS = 0;
|
2024-02-14 14:48:27 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 8.2.0
|
|
|
|
|
*/
|
2020-04-10 10:54:27 -04:00
|
|
|
public const STATUS_ERROR = 1;
|
2024-02-14 14:48:27 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 8.2.0
|
|
|
|
|
*/
|
2020-04-10 10:54:27 -04:00
|
|
|
public const STATUS_INDETERMINATE = 2;
|
2024-02-14 14:48:27 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 8.2.0
|
|
|
|
|
*/
|
2020-04-10 10:54:27 -04:00
|
|
|
public const STATUS_INCOMPLETE_CONF = 3;
|
2024-02-14 14:48:27 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 8.2.0
|
|
|
|
|
*/
|
2020-04-10 10:54:27 -04:00
|
|
|
public const STATUS_UNAUTHORIZED = 4;
|
2024-02-14 14:48:27 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 8.2.0
|
|
|
|
|
*/
|
2020-04-10 10:54:27 -04:00
|
|
|
public const STATUS_TIMEOUT = 5;
|
2024-02-14 14:48:27 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 8.2.0
|
|
|
|
|
*/
|
2020-04-10 10:54:27 -04:00
|
|
|
public const STATUS_NETWORK_ERROR = 6;
|
2015-11-26 02:26:07 -05:00
|
|
|
|
2015-11-09 04:38:39 -05:00
|
|
|
/**
|
|
|
|
|
* StorageNotAvailableException constructor.
|
|
|
|
|
*
|
|
|
|
|
* @param string $message
|
|
|
|
|
* @param int $code
|
2017-07-19 13:44:10 -04:00
|
|
|
* @param \Exception|null $previous
|
2015-11-09 04:38:39 -05:00
|
|
|
* @since 6.0.0
|
|
|
|
|
*/
|
2024-03-28 11:13:19 -04:00
|
|
|
public function __construct($message = '', $code = self::STATUS_ERROR, ?\Exception $previous = null) {
|
2023-09-26 04:42:38 -04:00
|
|
|
$l = \OCP\Util::getL10N('core');
|
2016-09-19 06:17:06 -04:00
|
|
|
parent::__construct($message, $l->t('Storage is temporarily not available'), $code, $previous);
|
2015-11-09 04:38:39 -05:00
|
|
|
}
|
2016-02-05 10:23:22 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the name for a status code
|
|
|
|
|
*
|
|
|
|
|
* @param int $code
|
|
|
|
|
* @return string
|
|
|
|
|
* @since 9.0.0
|
|
|
|
|
*/
|
|
|
|
|
public static function getStateCodeName($code) {
|
|
|
|
|
switch ($code) {
|
|
|
|
|
case self::STATUS_SUCCESS:
|
|
|
|
|
return 'ok';
|
|
|
|
|
case self::STATUS_ERROR:
|
|
|
|
|
return 'error';
|
|
|
|
|
case self::STATUS_INDETERMINATE:
|
|
|
|
|
return 'indeterminate';
|
|
|
|
|
case self::STATUS_UNAUTHORIZED:
|
|
|
|
|
return 'unauthorized';
|
|
|
|
|
case self::STATUS_TIMEOUT:
|
|
|
|
|
return 'timeout';
|
|
|
|
|
case self::STATUS_NETWORK_ERROR:
|
|
|
|
|
return 'network error';
|
|
|
|
|
default:
|
|
|
|
|
return 'unknown';
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-06-30 09:46:37 -04:00
|
|
|
}
|