The package defines five exception classes in Nwidart\Modules\Exceptions. Each extends \Exception. None of them adds a property or a method, except the static factory methods that InvalidActivatorClass and InvalidAssetPath provide.
FileRepository::findOrFail(), plus callers that forward it: isEnabled(), isDisabled(), enable(), disable(), delete(), setUsed(), getUsedNow(), module_path(), GeneratorCommand::module(), and ModuleCommandTrait::getModuleName().
Thrown when
A module does not exist, or no module is in use (getUsedNow()). Package commands validate names first, print Module [<name>] does not exist., and return 1 instead of throwing.
Message
Module [<name>] does not exist!
Two callers catch it: module() returns false, and FileRepository::getModulePath() returns the path the module would have. find() and has() never throw it.
use Nwidart\Modules\Exceptions\ModuleNotFoundException;
Json::decodeContents(), and so new Json(), Json::make() and the reading of module.json and composer.json. The FileActivator constructor.
Thrown when
A file is not valid JSON. Json also rejects empty files. FileActivator rejects invalid JSON, non-objects, and non-empty lists rather than overwriting the file on the next write.
Message
Json: Error processing file: <path>. Error: <json error>. FileActivator: The module statuses file [<path>] is not valid: <error>. Fix or restore the file (it maps module names to true or false).
A module.json that is not valid makes scan() throw, so every repository call that scans throws it.
use Nwidart\Modules\Exceptions\InvalidJsonException;
The container binding of ActivatorInterface, through three static factory methods.
Thrown when
unknownActivator($activator): modules.activator is not a string, modules.activators is not an array, or the key is missing. missingConfig(): the entry lacks a class key. classNotFound($activator, $class): the class does not exist.
Message
unknownActivator(): starts with The modules activator [<name>] is not defined.missingConfig(): starts with You don't have a valid activator configuration class. and tells you to republish the config. classNotFound(): starts with The class [<class>] of the modules activator [<activator>] does not exist.
use Nwidart\Modules\Contracts\ActivatorInterface;
use Nwidart\Modules\Exceptions\InvalidActivatorClass;
config(['modules.activator'=>'database']);
try {
app(ActivatorInterface::class);
} catch(InvalidActivatorClass$e) {
// The modules activator [database] is not defined. ...