1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Lack of Interest Better Exceptionmessage for the handler factories

Discussion in 'Closed Suggestions' started by Dan, Sep 11, 2013.

  1. Dan

    Dan Well-Known Member

    This code
    PHP:
    public static function create($class)
       {
         
    $class XenForo_Application::resolveDynamicClass($class);
         if (
    XenForo_Application::autoload($class))
         {
           
    $obj = new $class();
           if (
    $obj instanceof XenForo_AlertHandler_Abstract)
           {
             return 
    $obj;
           }
         }

         throw new 
    XenForo_Exception("Invalid user alert handler '$class' specified");
       }
    will throw always

    Invalid user alert handler '' specified
    if the class doesn't exist, resolveDynamicClass will return false and $class gets overwritten with false and won't contain the classname anymore.


    I would suggest to replace it with

    PHP:
    public static function create($class)
       {
         
    $classResolved XenForo_Application::resolveDynamicClass($class);
         if (
    XenForo_Application::autoload($classResolved ))
         {
           
    $obj = new $classResolved ();
           if (
    $obj instanceof XenForo_AlertHandler_Abstract)
           {
             return 
    $obj;
           }
         }

         throw new 
    XenForo_Exception("Invalid user alert handler '$class' specified");
       }
    because this way we'll get the classname which caused this problem instead of the empty string '' ;)
     
    Last edited by a moderator: Sep 11, 2013
    Liam W likes this.
  2. Liam W

    Liam W Well-Known Member

    Makes sense, no point in the message otherwise really ;)
     

Share This Page