浏览代码

Wrap token_get_all for better debuggability

Jordi Boggiano 13 年之前
父节点
当前提交
5c0c101327
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      src/Composer/Autoload/ClassMapGenerator.php

+ 5 - 1
src/Composer/Autoload/ClassMapGenerator.php

@@ -88,7 +88,11 @@ class ClassMapGenerator
     static private function findClasses($path)
     {
         $contents = file_get_contents($path);
-        $tokens   = token_get_all($contents);
+        try {
+            $tokens   = token_get_all($contents);
+        } catch (\Exception $e) {
+            throw new RuntimeException('Could not scan for classes inside '.$path.": \n".$e->getMessage(), 0, $e);
+        }
         $T_TRAIT  = version_compare(PHP_VERSION, '5.4', '<') ? -1 : T_TRAIT;
 
         $classes = array();