Lack of interest Better Exceptionmessage for the handler factories

This suggestion has been closed automatically because it did not receive enough votes over an extended period of time. If you wish to see this, please search for an open suggestion and, if you don't find any, post a new one.

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:
Upvote 1
This suggestion has been closed. Votes are no longer accepted.
Top Bottom