Exception.php

<?php

namespace Lia;


class Exception extends \Exception {

    const VIEW_NOT_FOUND = "View '%s' has not been added to Liaison.";
    const CANNOT_COPY_NONEXISTENT_VIEW_NS = "Cannot change '%s' view namespace to '%s', because the original namespace does not exist.";
    const CANNOT_OVERWRITE_EXISTING_VIEW = "Cannot override view '%s' with the same-named view from namespace '%s'";
    const ONLY_ONE_VIEW_LOADED_HOOK_ALLOWED = "Only one view loaded hook is allowed.";
    const REQUEST_TARGET_NOT_HANDLED = "Url %s was requested and matched a route, but target could not be resolved. \nTarget is `%s`";
    const ADDON_NOT_SET = "Addon with fully qualified name '%s' has not been added. Available addons are: %s";
    const PACKAGE_NOT_SET = "Package with fully qualified name '%s' has not been added. Available packages are: %s";
    const ADDON_NOT_SET_FROM = "Addon with class '%s' and fqn '%s' is not available on the passed-in Liaison instance. Available addons are: %s"; 
    const ADDON_MUST_DECLARE_FQN = "Every addon MUST declare `public string \$fqn = 'fqn'`, where fqn SHOULD be like `vendor:package.addon_name`. Addon with class '%s' did not declare fqn.";
    const FILE_NOT_EXIST = "File '%s' does not exist";
    const FILETYPE_UNKNOWN =  "Cannot determine file type from path '%s', so cannot get content type headers.";
    const INTERNAL_ROUTING_ERROR = "Internal error. We were unable to perform routing for '%s'.";
    const ONLY_ONE_PATTERNS_LOADED_HOOK = "Only one hook may be registered to '".\Lia\Hooks::PACKAGE_ROUTE_PATTERNS_LOADED."'. %s were registered.";
    const CACHE_DIR_NOT_EXIST = "The cache directory '%s' does not exist, thus cannot be checked for stale files.";
    const ROUTES_NOT_FOUND = "No routes were found for this request to `%s`";
    const INVALID_RESOURCE_EXTENSION = "Only js and css are allowed at this time, but '%s' was given.";
    const ERROR_GOTO_MESSAGE_NOT_AVAILABLE = "Error::goto message is not yet setup";
    const MUST_CONFIGURE_FIRST = "Lia::configure() MUST be called BEFORE any packages or addons are added.";
    const CONFIGURABLE_ADDON_NOT_FOUND = "Addon '%s' does not exist on package '%s', so it cannot be configured. Available addons are: %s.";
    const CANNOT_SET_CONFIG = "Cannot set config '%s' on addon '%s' of class '%s'. Exception Message: %s";


    /**
     * @param $exception_message should be a message named on this class
     * @param $strings as will be passed to sprintf()
     */
    public function __construct(string $exception_message, ...$strings){
        $full_message = sprintf($exception_message,...$strings);
        parent::__construct($full_message);
    }

}