registration: Throw more obvious error when a file doesn't exist
authorKunal Mehta <legoktm@gmail.com>
Mon, 4 May 2015 17:13:18 +0000 (10:13 -0700)
committerKunal Mehta <legoktm@gmail.com>
Mon, 4 May 2015 17:15:08 +0000 (10:15 -0700)
Previously it was saying the file that didn't exist wasn't valid JSON,
which was confusing.

Change-Id: I8381295ffcaba4e0dbfe9b93bdad80f86c119129

includes/registration/ExtensionRegistry.php

index 5ef3853..74d49bc 100644 (file)
@@ -114,6 +114,9 @@ class ExtensionRegistry {
                $autoloadClasses = array();
                foreach ( $queue as $path => $mtime ) {
                        $json = file_get_contents( $path );
+                       if ( $json === false ) {
+                               throw new Exception( "Unable to read $path, does it exist?" );
+                       }
                        $info = json_decode( $json, /* $assoc = */ true );
                        if ( !is_array( $info ) ) {
                                throw new Exception( "$path is not a valid JSON file." );