nextcloud/lib/public/User/Exceptions/UserNotFoundException.php
Carl Schwan da0928827a refactor: Expose a public exception when no user is found
And use this new exception everywhere outside of where the old one was
throw.

Signed-off-by: Carl Schwan <carlschwan@kde.org>
2026-06-30 21:56:10 +02:00

31 lines
776 B
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCP\User\Exceptions;
use OCP\AppFramework\Attribute\Catchable;
use OCP\AppFramework\Attribute\Throwable;
/**
* The class UserNotFoundException is thrown when no user is found.
*
* @since 35.0.0
*/
#[Throwable(since: '35.0.0')]
#[Catchable(since: '35.0.0')]
class UserNotFoundException extends \Exception {
/**
* Return a UserNotFoundException with a standard error message.
*
* @since 35.0.0
*/
public static function createForUser(string $userId, ?\Exception $previous = null): self {
return new UserNotFoundException('User with ' . $userId . ' not found.', previous: $previous);
}
}