aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGary Kim <gary@garykim.dev>2021-06-29 19:20:33 -0400
committerGary Kim <gary@garykim.dev>2021-06-30 15:28:02 -0400
commitb78f3a57d1d05fb5f81ec8361139b64a3e54d7b0 (patch)
treec2051ba8b5b03b8e4152e7597a8a3ac4457980c6 /lib
parent6da9ccc9ee1e37932c6580e9831c74bbeeac741b (diff)
downloadnextcloud-server-b78f3a57d1d05fb5f81ec8361139b64a3e54d7b0.tar.gz
nextcloud-server-b78f3a57d1d05fb5f81ec8361139b64a3e54d7b0.zip
Migrate HintException to OCP
Signed-off-by: Gary Kim <gary@garykim.dev>
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php2
-rw-r--r--lib/composer/composer/autoload_classmap.php1
-rw-r--r--lib/composer/composer/autoload_static.php1
-rw-r--r--lib/private/AppFramework/App.php3
-rw-r--r--lib/private/Config.php2
-rw-r--r--lib/private/DatabaseSetupException.php2
-rw-r--r--lib/private/HintException.php71
-rw-r--r--lib/private/Installer.php1
-rw-r--r--lib/private/Log/ExceptionSerializer.php2
-rw-r--r--lib/private/Log/Systemdlog.php2
-rw-r--r--lib/private/Memcache/Factory.php4
-rw-r--r--lib/private/Memcache/Memcached.php2
-rw-r--r--lib/private/Setup.php2
-rw-r--r--lib/private/Share20/Manager.php2
-rw-r--r--lib/private/Updater.php1
-rw-r--r--lib/private/User/Manager.php2
-rw-r--r--lib/private/legacy/OC_Hook.php4
-rw-r--r--lib/private/legacy/OC_Util.php12
-rw-r--r--lib/public/Encryption/Exceptions/GenericEncryptionException.php2
-rw-r--r--lib/public/Federation/Exceptions/ActionNotSupportedException.php2
-rw-r--r--lib/public/Federation/Exceptions/AuthenticationFailedException.php2
-rw-r--r--lib/public/Federation/Exceptions/BadRequestException.php2
-rw-r--r--lib/public/Federation/Exceptions/ProviderAlreadyExistsException.php2
-rw-r--r--lib/public/Federation/Exceptions/ProviderCouldNotAddShareException.php2
-rw-r--r--lib/public/Federation/Exceptions/ProviderDoesNotExistsException.php2
-rw-r--r--lib/public/Files/StorageNotAvailableException.php2
-rw-r--r--lib/public/HintException.php82
-rw-r--r--lib/public/Share/Exceptions/GenericShareException.php2
28 files changed, 134 insertions, 82 deletions
diff --git a/lib/base.php b/lib/base.php
index 473a3419cb1..45d06da0303 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -388,7 +388,7 @@ class OC {
if (!empty($incompatibleShippedApps)) {
$l = \OC::$server->getL10N('core');
$hint = $l->t('The files of the app %1$s were not replaced correctly. Make sure it is a version compatible with the server.', [implode(', ', $incompatibleShippedApps)]);
- throw new \OC\HintException('The files of the app ' . implode(', ', $incompatibleShippedApps) . ' were not replaced correctly. Make sure it is a version compatible with the server.', $hint);
+ throw new \OCP\HintException('The files of the app ' . implode(', ', $incompatibleShippedApps) . ' were not replaced correctly. Make sure it is a version compatible with the server.', $hint);
}
$tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion));
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 55d02c2feeb..82c40c800a4 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -371,6 +371,7 @@ return array(
'OCP\\Group\\Events\\UserAddedEvent' => $baseDir . '/lib/public/Group/Events/UserAddedEvent.php',
'OCP\\Group\\Events\\UserRemovedEvent' => $baseDir . '/lib/public/Group/Events/UserRemovedEvent.php',
'OCP\\Group\\ISubAdmin' => $baseDir . '/lib/public/Group/ISubAdmin.php',
+ 'OCP\\HintException' => $baseDir . '/lib/public/HintException.php',
'OCP\\Http\\Client\\IClient' => $baseDir . '/lib/public/Http/Client/IClient.php',
'OCP\\Http\\Client\\IClientService' => $baseDir . '/lib/public/Http/Client/IClientService.php',
'OCP\\Http\\Client\\IResponse' => $baseDir . '/lib/public/Http/Client/IResponse.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index 6f2bb064fc0..423fd814d6b 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -400,6 +400,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OCP\\Group\\Events\\UserAddedEvent' => __DIR__ . '/../../..' . '/lib/public/Group/Events/UserAddedEvent.php',
'OCP\\Group\\Events\\UserRemovedEvent' => __DIR__ . '/../../..' . '/lib/public/Group/Events/UserRemovedEvent.php',
'OCP\\Group\\ISubAdmin' => __DIR__ . '/../../..' . '/lib/public/Group/ISubAdmin.php',
+ 'OCP\\HintException' => __DIR__ . '/../../..' . '/lib/public/HintException.php',
'OCP\\Http\\Client\\IClient' => __DIR__ . '/../../..' . '/lib/public/Http/Client/IClient.php',
'OCP\\Http\\Client\\IClientService' => __DIR__ . '/../../..' . '/lib/public/Http/Client/IClientService.php',
'OCP\\Http\\Client\\IResponse' => __DIR__ . '/../../..' . '/lib/public/Http/Client/IResponse.php',
diff --git a/lib/private/AppFramework/App.php b/lib/private/AppFramework/App.php
index 37cc0b71e3f..6c2f905afa5 100644
--- a/lib/private/AppFramework/App.php
+++ b/lib/private/AppFramework/App.php
@@ -34,11 +34,11 @@ namespace OC\AppFramework;
use OC\AppFramework\DependencyInjection\DIContainer;
use OC\AppFramework\Http\Dispatcher;
use OC\AppFramework\Http\Request;
-use OC\HintException;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\ICallbackResponse;
use OCP\AppFramework\Http\IOutput;
use OCP\AppFramework\QueryException;
+use OCP\HintException;
use OCP\IRequest;
/**
@@ -105,6 +105,7 @@ class App {
/**
* Shortcut for calling a controller method and printing the result
+ *
* @param string $controllerName the name of the controller under which it is
* stored in the DI container
* @param string $methodName the method that you want to call
diff --git a/lib/private/Config.php b/lib/private/Config.php
index e3ace96c359..2a83d2300dc 100644
--- a/lib/private/Config.php
+++ b/lib/private/Config.php
@@ -38,6 +38,8 @@
*/
namespace OC;
+use OCP\HintException;
+
/**
* This class is responsible for reading and writing config.php, the very basic
* configuration file of Nextcloud.
diff --git a/lib/private/DatabaseSetupException.php b/lib/private/DatabaseSetupException.php
index b1b4956db41..44583416dbc 100644
--- a/lib/private/DatabaseSetupException.php
+++ b/lib/private/DatabaseSetupException.php
@@ -22,5 +22,7 @@
*/
namespace OC;
+use OCP\HintException;
+
class DatabaseSetupException extends HintException {
}
diff --git a/lib/private/HintException.php b/lib/private/HintException.php
index e3173ba79fd..735832266cf 100644
--- a/lib/private/HintException.php
+++ b/lib/private/HintException.php
@@ -1,28 +1,28 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @copyright Copyright (c) 2021 Gary Kim <gary@garykim.dev>
*
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Bart Visscher <bartv@thisnet.nl>
- * @author Lukas Reschke <lukas@statuscode.ch>
- * @author Michael Gapczynski <GapczynskiM@gmail.com>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
+ * @author Gary Kim <gary@garykim.dev>
*
- * @license AGPL-3.0
+ * @license GNU AGPL version 3 or any later version
*
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
+
namespace OC;
/**
@@ -31,48 +31,7 @@ namespace OC;
* An Exception class with the intention to be presented to the end user
*
* @package OC
+ * @depreacted 23.0.0 Use \OCP\HintException
*/
-class HintException extends \Exception {
- private $hint;
-
- /**
- * HintException constructor.
- *
- * @param string $message The error message. It will be not revealed to the
- * the user (unless the hint is empty) and thus
- * should be not translated.
- * @param string $hint A useful message that is presented to the end
- * user. It should be translated, but must not
- * contain sensitive data.
- * @param int $code
- * @param \Exception|null $previous
- */
- public function __construct($message, $hint = '', $code = 0, \Exception $previous = null) {
- $this->hint = $hint;
- parent::__construct($message, $code, $previous);
- }
-
- /**
- * Returns a string representation of this Exception that includes the error
- * code, the message and the hint.
- *
- * @return string
- */
- public function __toString() {
- return __CLASS__ . ": [{$this->code}]: {$this->message} ({$this->hint})\n";
- }
-
- /**
- * Returns the hint with the intention to be presented to the end user. If
- * an empty hint was specified upon instatiation, the message is returned
- * instead.
- *
- * @return string
- */
- public function getHint() {
- if (empty($this->hint)) {
- return $this->message;
- }
- return $this->hint;
- }
+class HintException extends \OCP\HintException {
}
diff --git a/lib/private/Installer.php b/lib/private/Installer.php
index d1e903424ed..19e70aad147 100644
--- a/lib/private/Installer.php
+++ b/lib/private/Installer.php
@@ -48,6 +48,7 @@ use OC\DB\Connection;
use OC\DB\MigrationService;
use OC_App;
use OC_Helper;
+use OCP\HintException;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\ILogger;
diff --git a/lib/private/Log/ExceptionSerializer.php b/lib/private/Log/ExceptionSerializer.php
index aba5586297a..bab22ab4aac 100644
--- a/lib/private/Log/ExceptionSerializer.php
+++ b/lib/private/Log/ExceptionSerializer.php
@@ -29,10 +29,10 @@
namespace OC\Log;
use OC\Core\Controller\SetupController;
-use OC\HintException;
use OC\Security\IdentityProof\Key;
use OC\Setup;
use OC\SystemConfig;
+use OCP\HintException;
class ExceptionSerializer {
public const methodsWithSensitiveParameters = [
diff --git a/lib/private/Log/Systemdlog.php b/lib/private/Log/Systemdlog.php
index 17778891efe..a01826c0b05 100644
--- a/lib/private/Log/Systemdlog.php
+++ b/lib/private/Log/Systemdlog.php
@@ -25,8 +25,8 @@
*/
namespace OC\Log;
-use OC\HintException;
use OC\SystemConfig;
+use OCP\HintException;
use OCP\ILogger;
use OCP\Log\IWriter;
diff --git a/lib/private/Memcache/Factory.php b/lib/private/Memcache/Factory.php
index 9810f068148..28a84308edc 100644
--- a/lib/private/Memcache/Factory.php
+++ b/lib/private/Memcache/Factory.php
@@ -86,12 +86,12 @@ class Factory implements ICacheFactory {
$missingCacheMessage = 'Memcache {class} not available for {use} cache';
$missingCacheHint = 'Is the matching PHP module installed and enabled?';
if (!class_exists($localCacheClass) || !$localCacheClass::isAvailable()) {
- throw new \OC\HintException(strtr($missingCacheMessage, [
+ throw new \OCP\HintException(strtr($missingCacheMessage, [
'{class}' => $localCacheClass, '{use}' => 'local'
]), $missingCacheHint);
}
if (!class_exists($distributedCacheClass) || !$distributedCacheClass::isAvailable()) {
- throw new \OC\HintException(strtr($missingCacheMessage, [
+ throw new \OCP\HintException(strtr($missingCacheMessage, [
'{class}' => $distributedCacheClass, '{use}' => 'distributed'
]), $missingCacheHint);
}
diff --git a/lib/private/Memcache/Memcached.php b/lib/private/Memcache/Memcached.php
index cd1af031d8a..b3414a7d290 100644
--- a/lib/private/Memcache/Memcached.php
+++ b/lib/private/Memcache/Memcached.php
@@ -31,7 +31,7 @@
*/
namespace OC\Memcache;
-use OC\HintException;
+use OCP\HintException;
use OCP\IMemcache;
class Memcached extends Cache implements IMemcache {
diff --git a/lib/private/Setup.php b/lib/private/Setup.php
index 8e7e6ae6aea..d39fa069286 100644
--- a/lib/private/Setup.php
+++ b/lib/private/Setup.php
@@ -224,7 +224,7 @@ class Setup {
try {
$util = new \OC_Util();
$htAccessWorking = $util->isHtaccessWorking(\OC::$server->getConfig());
- } catch (\OC\HintException $e) {
+ } catch (\OCP\HintException $e) {
$errors[] = [
'error' => $e->getMessage(),
'exception' => $e,
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index b5e1b944bc5..7047c32e339 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -43,7 +43,6 @@ namespace OC\Share20;
use OC\Cache\CappedMemoryCache;
use OC\Files\Mount\MoveableMount;
-use OC\HintException;
use OC\Share20\Exception\ProviderException;
use OCA\Files_Sharing\ISharedStorage;
use OCP\EventDispatcher\IEventDispatcher;
@@ -52,6 +51,7 @@ use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountManager;
use OCP\Files\Node;
+use OCP\HintException;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IL10N;
diff --git a/lib/private/Updater.php b/lib/private/Updater.php
index 5fa41e48c0c..cffdac310cb 100644
--- a/lib/private/Updater.php
+++ b/lib/private/Updater.php
@@ -45,6 +45,7 @@ use OC\DB\MigrationService;
use OC\Hooks\BasicEmitter;
use OC\IntegrityCheck\Checker;
use OC_App;
+use OCP\HintException;
use OCP\IConfig;
use OCP\ILogger;
use OCP\Util;
diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php
index 07a599cf017..12c615d500b 100644
--- a/lib/private/User/Manager.php
+++ b/lib/private/User/Manager.php
@@ -33,10 +33,10 @@
*/
namespace OC\User;
-use OC\HintException;
use OC\Hooks\PublicEmitter;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\HintException;
use OCP\ICache;
use OCP\ICacheFactory;
use OCP\IConfig;
diff --git a/lib/private/legacy/OC_Hook.php b/lib/private/legacy/OC_Hook.php
index d9e4c99e498..b223b0fa6d6 100644
--- a/lib/private/legacy/OC_Hook.php
+++ b/lib/private/legacy/OC_Hook.php
@@ -81,7 +81,7 @@ class OC_Hook {
* @param string $signalName name of signal
* @param mixed $params default: array() array with additional data
* @return bool true if slots exists or false if not
- * @throws \OC\HintException
+ * @throws \OCP\HintException
* @throws \OC\ServerNotAvailableException Emits a signal. To get data from the slot use references!
*
* TODO: write example
@@ -107,7 +107,7 @@ class OC_Hook {
} catch (Exception $e) {
self::$thrownExceptions[] = $e;
\OC::$server->getLogger()->logException($e);
- if ($e instanceof \OC\HintException) {
+ if ($e instanceof \OCP\HintException) {
throw $e;
}
if ($e instanceof \OC\ServerNotAvailableException) {
diff --git a/lib/private/legacy/OC_Util.php b/lib/private/legacy/OC_Util.php
index 87964f98374..333b621e359 100644
--- a/lib/private/legacy/OC_Util.php
+++ b/lib/private/legacy/OC_Util.php
@@ -63,6 +63,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
+
use bantu\IniGetWrapper\IniGetWrapper;
use OC\AppFramework\Http\Request;
use OC\Files\Storage\LocalRootStorage;
@@ -1214,7 +1215,7 @@ class OC_Util {
$fp = @fopen($testFile, 'w');
if (!$fp) {
- throw new OC\HintException('Can\'t create test file to check for working .htaccess file.',
+ throw new \OCP\HintException('Can\'t create test file to check for working .htaccess file.',
'Make sure it is possible for the webserver to write to ' . $testFile);
}
fwrite($fp, $testContent);
@@ -1225,10 +1226,11 @@ class OC_Util {
/**
* Check if the .htaccess file is working
+ *
* @param \OCP\IConfig $config
* @return bool
* @throws Exception
- * @throws \OC\HintException If the test file can't get written.
+ * @throws \OCP\HintException If the test file can't get written.
*/
public function isHtaccessWorking(\OCP\IConfig $config) {
if (\OC::$CLI || !$config->getSystemValue('check_for_working_htaccess', true)) {
@@ -1422,7 +1424,7 @@ class OC_Util {
*
* @param \OC\SystemConfig $config
* @return bool whether the core or any app needs an upgrade
- * @throws \OC\HintException When the upgrade from the given version is not allowed
+ * @throws \OCP\HintException When the upgrade from the given version is not allowed
*/
public static function needUpgrade(\OC\SystemConfig $config) {
if ($config->getValue('installed', false)) {
@@ -1442,11 +1444,11 @@ class OC_Util {
return true;
} else {
// downgrade attempt, throw exception
- throw new \OC\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')');
+ throw new \OCP\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')');
}
} elseif ($versionDiff < 0) {
// downgrade attempt, throw exception
- throw new \OC\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')');
+ throw new \OCP\HintException('Downgrading is not supported and is likely to cause unpredictable issues (from ' . $installedVersion . ' to ' . $currentVersion . ')');
}
// also check for upgrades for apps (independently from the user)
diff --git a/lib/public/Encryption/Exceptions/GenericEncryptionException.php b/lib/public/Encryption/Exceptions/GenericEncryptionException.php
index 9f349a28a76..aef4114bb1b 100644
--- a/lib/public/Encryption/Exceptions/GenericEncryptionException.php
+++ b/lib/public/Encryption/Exceptions/GenericEncryptionException.php
@@ -26,7 +26,7 @@
*/
namespace OCP\Encryption\Exceptions;
-use OC\HintException;
+use OCP\HintException;
/**
* Class GenericEncryptionException
diff --git a/lib/public/Federation/Exceptions/ActionNotSupportedException.php b/lib/public/Federation/Exceptions/ActionNotSupportedException.php
index 3ec729e415a..7b2ca3d9597 100644
--- a/lib/public/Federation/Exceptions/ActionNotSupportedException.php
+++ b/lib/public/Federation/Exceptions/ActionNotSupportedException.php
@@ -22,7 +22,7 @@
*/
namespace OCP\Federation\Exceptions;
-use OC\HintException;
+use OCP\HintException;
/**
* Class ActionNotSupportedException
diff --git a/lib/public/Federation/Exceptions/AuthenticationFailedException.php b/lib/public/Federation/Exceptions/AuthenticationFailedException.php
index 61ea080f5d4..dfcd9636035 100644
--- a/lib/public/Federation/Exceptions/AuthenticationFailedException.php
+++ b/lib/public/Federation/Exceptions/AuthenticationFailedException.php
@@ -22,7 +22,7 @@
*/
namespace OCP\Federation\Exceptions;
-use OC\HintException;
+use OCP\HintException;
/**
* Class AuthenticationFailedException
diff --git a/lib/public/Federation/Exceptions/BadRequestException.php b/lib/public/Federation/Exceptions/BadRequestException.php
index bea6fba2b18..8054c0e89f0 100644
--- a/lib/public/Federation/Exceptions/BadRequestException.php
+++ b/lib/public/Federation/Exceptions/BadRequestException.php
@@ -23,7 +23,7 @@
*/
namespace OCP\Federation\Exceptions;
-use OC\HintException;
+use OCP\HintException;
/**
* Class BadRequestException
diff --git a/lib/public/Federation/Exceptions/ProviderAlreadyExistsException.php b/lib/public/Federation/Exceptions/ProviderAlreadyExistsException.php
index 48aa883a028..b6d4b7e9bce 100644
--- a/lib/public/Federation/Exceptions/ProviderAlreadyExistsException.php
+++ b/lib/public/Federation/Exceptions/ProviderAlreadyExistsException.php
@@ -24,7 +24,7 @@
*/
namespace OCP\Federation\Exceptions;
-use OC\HintException;
+use OCP\HintException;
/**
* Class ProviderAlreadyExistsException
diff --git a/lib/public/Federation/Exceptions/ProviderCouldNotAddShareException.php b/lib/public/Federation/Exceptions/ProviderCouldNotAddShareException.php
index c647b2d9c9e..efcc8788386 100644
--- a/lib/public/Federation/Exceptions/ProviderCouldNotAddShareException.php
+++ b/lib/public/Federation/Exceptions/ProviderCouldNotAddShareException.php
@@ -22,8 +22,8 @@
*/
namespace OCP\Federation\Exceptions;
-use OC\HintException;
use OCP\AppFramework\Http;
+use OCP\HintException;
/**
* Class ProviderCouldNotAddShareException
diff --git a/lib/public/Federation/Exceptions/ProviderDoesNotExistsException.php b/lib/public/Federation/Exceptions/ProviderDoesNotExistsException.php
index b56a6ef8d4c..69c69f17d99 100644
--- a/lib/public/Federation/Exceptions/ProviderDoesNotExistsException.php
+++ b/lib/public/Federation/Exceptions/ProviderDoesNotExistsException.php
@@ -22,7 +22,7 @@
*/
namespace OCP\Federation\Exceptions;
-use OC\HintException;
+use OCP\HintException;
/**
* Class ProviderDoesNotExistsException
diff --git a/lib/public/Files/StorageNotAvailableException.php b/lib/public/Files/StorageNotAvailableException.php
index e166df90d77..f600ef80808 100644
--- a/lib/public/Files/StorageNotAvailableException.php
+++ b/lib/public/Files/StorageNotAvailableException.php
@@ -32,7 +32,7 @@
namespace OCP\Files;
-use OC\HintException;
+use OCP\HintException;
/**
* Storage is temporarily not available
diff --git a/lib/public/HintException.php b/lib/public/HintException.php
new file mode 100644
index 00000000000..b5ee7642b03
--- /dev/null
+++ b/lib/public/HintException.php
@@ -0,0 +1,82 @@
+<?php
+/**
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ *
+ * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
+ * @author Bart Visscher <bartv@thisnet.nl>
+ * @author Lukas Reschke <lukas@statuscode.ch>
+ * @author Michael Gapczynski <GapczynskiM@gmail.com>
+ * @author Thomas Müller <thomas.mueller@tmit.eu>
+ *
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+namespace OCP;
+
+/**
+ * Class HintException
+ *
+ * An Exception class with the intention to be presented to the end user
+ *
+ * @package OCP
+ * @since 23.0.0
+ */
+class HintException extends \Exception {
+ private $hint;
+
+ /**
+ * HintException constructor.
+ *
+ * @since 23.0.0
+ * @param string $message The error message. It will be not revealed to the
+ * the user (unless the hint is empty) and thus
+ * should be not translated.
+ * @param string $hint A useful message that is presented to the end
+ * user. It should be translated, but must not
+ * contain sensitive data.
+ * @param int $code
+ * @param \Exception|null $previous
+ */
+ public function __construct($message, $hint = '', $code = 0, \Exception $previous = null) {
+ $this->hint = $hint;
+ parent::__construct($message, $code, $previous);
+ }
+
+ /**
+ * Returns a string representation of this Exception that includes the error
+ * code, the message and the hint.
+ *
+ * @since 23.0.0
+ * @return string
+ */
+ public function __toString(): string {
+ return __CLASS__ . ": [{$this->code}]: {$this->message} ({$this->hint})\n";
+ }
+
+ /**
+ * Returns the hint with the intention to be presented to the end user. If
+ * an empty hint was specified upon instatiation, the message is returned
+ * instead.
+ *
+ * @since 23.0.0
+ * @return string
+ */
+ public function getHint(): string {
+ if (empty($this->hint)) {
+ return $this->message;
+ }
+ return $this->hint;
+ }
+}
diff --git a/lib/public/Share/Exceptions/GenericShareException.php b/lib/public/Share/Exceptions/GenericShareException.php
index 46a46ac0ab7..85c440e2387 100644
--- a/lib/public/Share/Exceptions/GenericShareException.php
+++ b/lib/public/Share/Exceptions/GenericShareException.php
@@ -24,7 +24,7 @@
*/
namespace OCP\Share\Exceptions;
-use OC\HintException;
+use OCP\HintException;
/**
* Class GenericEncryptionException