namespace OCA\Encryption\Command;
use OC\Files\View;
-use OC\HintException;
use OCA\Encryption\Util;
use OCP\Files\IRootFolder;
+use OCP\HintException;
use OCP\IConfig;
use OCP\ILogger;
use OCP\IUserManager;
*/
namespace OCA\FederatedFileSharing;
-use OC\HintException;
use OCP\Federation\ICloudIdManager;
+use OCP\HintException;
use OCP\IL10N;
use OCP\IURLGenerator;
*/
namespace OCA\FederatedFileSharing\Controller;
-use OC\HintException;
use OCA\FederatedFileSharing\AddressHandler;
use OCA\FederatedFileSharing\FederatedShareProvider;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse;
use OCP\Constants;
use OCP\Federation\ICloudIdManager;
+use OCP\HintException;
use OCP\Http\Client\IClientService;
use OCP\IL10N;
use OCP\ILogger;
* @return Http\DataResponse
* @throws OCSException
* @throws ShareNotFound
- * @throws \OC\HintException
+ * @throws \OCP\HintException
*/
public function acceptShare($id) {
$token = isset($_POST['token']) ? $_POST['token'] : null;
*
* @param IShare $share
* @throws ShareNotFound
- * @throws \OC\HintException
+ * @throws \OCP\HintException
*/
protected function sendPermissionUpdate(IShare $share) {
$remoteId = $this->getRemoteId($share);
*
* @param IShare $share
* @throws ShareNotFound
- * @throws \OC\HintException
+ * @throws \OCP\HintException
*/
public function delete(IShare $share) {
[, $remote] = $this->addressHandler->splitUserRemote($share->getSharedWith());
* @param IShare $share
* @param bool $isOwner the user can either be the owner or the user who re-sahred it
* @throws ShareNotFound
- * @throws \OC\HintException
+ * @throws \OCP\HintException
*/
protected function revokeShare($share, $isOwner) {
if ($this->userManager->userExists($share->getShareOwner()) && $this->userManager->userExists($share->getSharedBy())) {
use OCP\Federation\ICloudFederationFactory;
use OCP\Federation\ICloudFederationProviderManager;
use OCP\Http\Client\IClientService;
-use OCP\OCS\IDiscoveryService;
use OCP\ILogger;
+use OCP\OCS\IDiscoveryService;
class Notifications {
public const RESPONSE_FORMAT = 'json'; // default response format for ocs calls
* @param string $sharedByFederatedId
* @param int $shareType (can be a remote user or group share)
* @return bool
- * @throws \OC\HintException
+ * @throws \OCP\HintException
* @throws \OC\ServerNotAvailableException
*/
public function sendRemoteShare($token, $shareWith, $name, $remoteId, $owner, $ownerFederatedId, $sharedBy, $sharedByFederatedId, $shareType) {
* @param int $permission
* @param string $filename
* @return array|false
- * @throws \OC\HintException
+ * @throws \OCP\HintException
* @throws \OC\ServerNotAvailableException
*/
public function requestReShare($token, $id, $shareId, $remote, $shareWith, $permission, $filename) {
*/
namespace OCA\FederatedFileSharing;
-use OC\HintException;
use OCP\Contacts\IManager;
use OCP\Federation\ICloudId;
use OCP\Federation\ICloudIdManager;
+use OCP\HintException;
use OCP\IURLGenerator;
use OCP\L10N\IFactory;
use OCP\Notification\INotification;
use OC\AppFramework\Http;
use OC\Files\Filesystem;
-use OC\HintException;
use OCA\FederatedFileSharing\AddressHandler;
use OCA\FederatedFileSharing\FederatedShareProvider;
use OCA\Files_Sharing\Activity\Providers\RemoteShares;
use OCP\Federation\ICloudFederationShare;
use OCP\Federation\ICloudIdManager;
use OCP\Files\NotFoundException;
+use OCP\HintException;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IGroupManager;
use OCP\IURLGenerator;
use OCP\IUserManager;
use OCP\Notification\IManager as INotificationManager;
-use OCP\Share;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager;
use OCP\Share\IShare;
*
* @throws ProviderCouldNotAddShareException
* @throws \OCP\AppFramework\QueryException
- * @throws \OC\HintException
+ * @throws HintException
* @since 14.0.0
*/
public function shareReceived(ICloudFederationShare $share) {
* @throws ActionNotSupportedException
* @throws AuthenticationFailedException
* @throws BadRequestException
- * @throws \OC\HintException
+ * @throws HintException
* @since 14.0.0
*/
public function notificationReceived($notificationType, $providerId, array $notification) {
* @throws ActionNotSupportedException
* @throws AuthenticationFailedException
* @throws BadRequestException
- * @throws \OC\HintException
+ * @throws HintException
*/
private function shareAccepted($id, array $notification) {
if (!$this->isS2SEnabled()) {
* @throws AuthenticationFailedException
* @throws BadRequestException
* @throws ShareNotFound
- * @throws \OC\HintException
+ * @throws HintException
*
*/
protected function shareDeclined($id, array $notification) {
* @param string $id
*/
public function testSplitUserRemoteError($id) {
- $this->expectException(\OC\HintException::class);
+ $this->expectException(\OCP\HintException::class);
$this->addressHandler->splitUserRemote($id);
}
namespace OCA\FederatedFileSharing\Tests\Controller;
use OC\Federation\CloudIdManager;
-use OC\HintException;
use OCA\FederatedFileSharing\AddressHandler;
use OCA\FederatedFileSharing\Controller\MountPublicLinkController;
use OCA\FederatedFileSharing\FederatedShareProvider;
use OCP\Contacts\IManager as IContactsManager;
use OCP\Federation\ICloudIdManager;
use OCP\Files\IRootFolder;
+use OCP\HintException;
use OCP\Http\Client\IClientService;
use OCP\IL10N;
use OCP\IRequest;
*/
namespace OCA\Federation\Controller;
-use OC\HintException;
use OCA\Federation\TrustedServers;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse;
+use OCP\HintException;
use OCP\IL10N;
use OCP\IRequest;
namespace OCA\Federation;
use OC\Files\Filesystem;
-use OC\HintException;
+use OCP\HintException;
use OCP\IDBConnection;
use OCP\IL10N;
*/
namespace OCA\Federation\Middleware;
-use OC\HintException;
use OCA\Federation\Controller\SettingsController;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Middleware;
+use OCP\HintException;
use OCP\IL10N;
use OCP\ILogger;
*/
namespace OCA\Federation;
-use OC\HintException;
use OCA\Federation\BackgroundJob\RequestSharedSecret;
use OCP\AppFramework\Http;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
+use OCP\HintException;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\ILogger;
* @param bool $isOwnCloud
*/
public function testAddServerFail($isTrustedServer, $isOwnCloud) {
- $this->expectException(\OC\HintException::class);
+ $this->expectException(\OCP\HintException::class);
$this->trustedServers
->expects($this->any())
* @param bool $isOwnCloud
*/
public function testCheckServerFail($isTrustedServer, $isOwnCloud) {
- $this->expectException(\OC\HintException::class);
+ $this->expectException(\OCP\HintException::class);
$this->trustedServers
->expects($this->any())
*/
namespace OCA\Federation\Tests\Middleware;
-use OC\HintException;
use OCA\Federation\Controller\SettingsController;
use OCA\Federation\Middleware\AddServerMiddleware;
use OCP\AppFramework\Http;
+use OCP\HintException;
use OCP\IL10N;
use OCP\ILogger;
use Test\TestCase;
* @dataProvider dataTestCheckOwnCloudVersionTooLow
*/
public function testCheckOwnCloudVersionTooLow($status) {
- $this->expectException(\OC\HintException::class);
+ $this->expectException(\OCP\HintException::class);
$this->expectExceptionMessage('Remote server version is too low. 9.0 is required.');
$this->invokePrivate($this->trustedServers, 'checkOwnCloudVersion', [$status]);
*/
namespace OCA\Files_Sharing\Controller;
+use OC\Security\CSP\ContentSecurityPolicy;
use OC_Files;
use OC_Util;
-use OC\Security\CSP\ContentSecurityPolicy;
use OCA\FederatedFileSharing\FederatedShareProvider;
use OCA\Files_Sharing\Activity\Providers\Downloads;
use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent;
* otherwise token
* @param int $errorCode
* @param string $errorMessage
- * @throws \OC\HintException
+ * @throws \OCP\HintException
* @throws \OC\ServerNotAvailableException
*/
protected function emitAccessShareHook($share, $errorCode = 200, $errorMessage = '') {
use libphonenumber\PhoneNumberFormat;
use libphonenumber\PhoneNumberUtil;
use OC\Authentication\Token\RemoteWipe;
-use OC\HintException;
use OC\KnownUser\KnownUserService;
use OC\User\Backend;
use OCA\Settings\Mailer\NewUserMailHelper;
use OCP\AppFramework\OCS\OCSException;
use OCP\AppFramework\OCS\OCSForbiddenException;
use OCP\AppFramework\OCSController;
+use OCP\EventDispatcher\IEventDispatcher;
+use OCP\HintException;
use OCP\IConfig;
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\L10N\IFactory;
-use OCP\Security\ISecureRandom;
use OCP\Security\Events\GenerateSecurePasswordEvent;
-use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Security\ISecureRandom;
use OCP\User\Backend\ISetDisplayNameBackend;
use Psr\Log\LoggerInterface;
namespace OCA\Settings\Controller;
use OC\Group\Manager as GroupManager;
-use OC\HintException;
use OC\User\Session;
use OCP\App\IAppManager;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse;
+use OCP\HintException;
use OCP\IGroupManager;
use OCP\IL10N;
use OCP\IRequest;
*/
namespace OCA\ShareByMail;
-use OC\HintException;
use OC\Share20\Exception\InvalidShare;
use OC\Share20\Share;
use OC\User\NoUserException;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
+use OCP\HintException;
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\ILogger;
public function testCreateMailShareFailed() {
- $this->expectException(\OC\HintException::class);
+ $this->expectException(\OCP\HintException::class);
$this->share->expects($this->any())->method('getToken')->willReturn('token');
$this->share->expects($this->once())->method('setToken')->with('token');
namespace OCA\User_LDAP;
use DomainException;
-use OC\HintException;
use OC\Hooks\PublicEmitter;
use OC\ServerNotAvailableException;
use OCA\User_LDAP\Exceptions\ConstraintViolationException;
use OCA\User_LDAP\Mapping\UserMapping;
use OCA\User_LDAP\User\Manager;
use OCA\User_LDAP\User\OfflineUser;
+use OCP\HintException;
use OCP\IConfig;
use OCP\ILogger;
use OCP\IUserManager;
*/
namespace OCA\User_LDAP\Controller;
-use OC\HintException;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\TemplateResponse;
+use OCP\HintException;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IRequest;
]);
return new RedirectResponse($this->urlGenerator->linkToRoute('user_ldap.renewPassword.showRenewPasswordForm', $args));
}
-
+
try {
if (!is_null($newPassword) && \OC_User::setPassword($user, $newPassword)) {
$this->session->set('loginMessages', [
public function testSetPasswordWithRejectedChange() {
- $this->expectException(\OC\HintException::class);
+ $this->expectException(\OCP\HintException::class);
$this->expectExceptionMessage('Password change rejected.');
$this->connection
*/
namespace OCA\User_LDAP\Tests;
-use OC\HintException;
use OC\User\Backend;
use OC\User\Session;
use OCA\User_LDAP\Access;
use OCA\User_LDAP\User_LDAP;
use OCA\User_LDAP\User_LDAP as UserLDAP;
use OCA\User_LDAP\UserPluginManager;
+use OCP\HintException;
use OCP\IConfig;
use OCP\IUser;
use OCP\Notification\IManager as INotificationManager;
public function testSetPasswordInvalid() {
- $this->expectException(\OC\HintException::class);
+ $this->expectException(\OCP\HintException::class);
$this->expectExceptionMessage('Password fails quality checking policy');
$this->prepareAccessForSetPassword($this->access);
public function testSetDisplayNameErrorWithPlugin() {
- $this->expectException(\OC\HintException::class);
+ $this->expectException(\OCP\HintException::class);
$newDisplayName = 'J. Baker';
$this->pluginManager->expects($this->once())
*/
namespace OC\Core\Controller;
-use function array_filter;
-use function count;
use OC\Authentication\TwoFactorAuth\Manager;
use OC\Core\Exception\ResetPasswordException;
-use OC\HintException;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\Defaults;
use OCP\Encryption\IEncryptionModule;
use OCP\Encryption\IManager;
+use OCP\HintException;
use OCP\IConfig;
use OCP\IInitialStateService;
use OCP\IL10N;
use OCP\Mail\IMailer;
use OCP\Security\ICrypto;
use OCP\Security\ISecureRandom;
+use function array_filter;
+use function count;
use function reset;
/**
//show the user a detailed error page
OC_Template::printExceptionErrorPage($ex, 503);
-} catch (\OC\HintException $ex) {
+} catch (\OCP\HintException $ex) {
try {
OC_Template::printErrorPage($ex->getMessage(), $ex->getHint(), 503);
} catch (Exception $ex2) {
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));
'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',
'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',
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;
/**
/**
* 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
*/
namespace OC;
+use OCP\HintException;
+
/**
* This class is responsible for reading and writing config.php, the very basic
* configuration file of Nextcloud.
*/
namespace OC;
+use OCP\HintException;
+
class DatabaseSetupException extends HintException {
}
<?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;
/**
* 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 {
}
use OC\DB\MigrationService;
use OC_App;
use OC_Helper;
+use OCP\HintException;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\ILogger;
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 = [
*/
namespace OC\Log;
-use OC\HintException;
use OC\SystemConfig;
+use OCP\HintException;
use OCP\ILogger;
use OCP\Log\IWriter;
$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);
}
*/
namespace OC\Memcache;
-use OC\HintException;
+use OCP\HintException;
use OCP\IMemcache;
class Memcached extends Cache implements IMemcache {
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,
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;
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;
use OC\Hooks\BasicEmitter;
use OC\IntegrityCheck\Checker;
use OC_App;
+use OCP\HintException;
use OCP\IConfig;
use OCP\ILogger;
use OCP\Util;
*/
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;
* @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
} 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) {
* 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;
$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);
/**
* 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)) {
*
* @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)) {
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)
*/
namespace OCP\Encryption\Exceptions;
-use OC\HintException;
+use OCP\HintException;
/**
* Class GenericEncryptionException
*/
namespace OCP\Federation\Exceptions;
-use OC\HintException;
+use OCP\HintException;
/**
* Class ActionNotSupportedException
*/
namespace OCP\Federation\Exceptions;
-use OC\HintException;
+use OCP\HintException;
/**
* Class AuthenticationFailedException
*/
namespace OCP\Federation\Exceptions;
-use OC\HintException;
+use OCP\HintException;
/**
* Class BadRequestException
*/
namespace OCP\Federation\Exceptions;
-use OC\HintException;
+use OCP\HintException;
/**
* Class ProviderAlreadyExistsException
*/
namespace OCP\Federation\Exceptions;
-use OC\HintException;
use OCP\AppFramework\Http;
+use OCP\HintException;
/**
* Class ProviderCouldNotAddShareException
*/
namespace OCP\Federation\Exceptions;
-use OC\HintException;
+use OCP\HintException;
/**
* Class ProviderDoesNotExistsException
namespace OCP\Files;
-use OC\HintException;
+use OCP\HintException;
/**
* Storage is temporarily not available
--- /dev/null
+<?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;
+ }
+}
*/
namespace OCP\Share\Exceptions;
-use OC\HintException;
+use OCP\HintException;
/**
* Class GenericEncryptionException
namespace Tests\Core\Controller;
-use OC\HintException;
use OC\User\Session;
use OCA\Settings\Controller\ChangePasswordController;
use OCP\App\IAppManager;
use OCP\AppFramework\Http\JSONResponse;
+use OCP\HintException;
use OCP\IGroupManager;
use OCP\IL10N;
use OCP\IRequest;
* @dataProvider cacheUnavailableProvider
*/
public function testCacheNotAvailableException($localCache, $distributedCache) {
- $this->expectException(\OC\HintException::class);
+ $this->expectException(\OCP\HintException::class);
$logger = $this->getMockBuilder(ILogger::class)->getMock();
new \OC\Memcache\Factory('abc', $logger, $localCache, $distributedCache);
namespace Test\Share20;
use OC\Files\Mount\MoveableMount;
-use OC\HintException;
use OC\Share20\DefaultShareProvider;
use OC\Share20\Exception;
use OC\Share20\Manager;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\Node;
use OCP\Files\Storage;
+use OCP\HintException;
use OCP\IConfig;
use OCP\IGroup;
use OCP\IGroupManager;
namespace Test\User;
-use OC\HintException;
use OC\User\User;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\HintException;
use OCP\Security\Events\ValidatePasswordPolicyEvent;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
$this->assertSame($user, $this->backend->checkPassword($user, 'newpass'));
}
-
+
public function testVerifyPasswordEventFail() {
- $this->expectException(\OC\HintException::class);
+ $this->expectException(\OCP\HintException::class);
$this->expectExceptionMessage('password change failed');
$user = $this->getUser();