Skip to content

Commit

Permalink
OXDEV-8489 Extended ModuleDeactivationException
Browse files Browse the repository at this point in the history
  • Loading branch information
RahatHameed committed Jul 15, 2024
1 parent eda1e03 commit 9a335e2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/Module/Exception/ModuleDeactivationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@

final class ModuleDeactivationException extends NotFound
{
public const EXCEPTION_MESSAGE = "This Module is in the blocklist and cannot be deactivated.";
public const EXCEPTION_MESSAGE = "An error occurred while deactivating the module.";
public const BLOCKED_MODULE_MESSAGE = 'Module "%s" is in the blocklist and cannot be deactivated.';

public function __construct()
public function __construct(string $message = null)
{
parent::__construct(self::EXCEPTION_MESSAGE);
if (empty($message)) {
$message = self::EXCEPTION_MESSAGE;
}
parent::__construct($message);
}
}
4 changes: 3 additions & 1 deletion src/Module/Service/ModuleSwitchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public function activateModule(string $moduleId): bool
public function deactivateModule(string $moduleId): bool
{
if ($this->moduleBlocklistService->isModuleBlocked($moduleId)) {
throw new ModuleDeactivationException();
throw new ModuleDeactivationException(
sprintf(ModuleDeactivationException::BLOCKED_MODULE_MESSAGE, $moduleId)
);
}
return $this->moduleSwitchInfrastructure->deactivateModule(moduleId: $moduleId);
}
Expand Down

0 comments on commit 9a335e2

Please sign in to comment.