Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15430519
D21029.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D21029.diff
View Options
diff --git a/src/init/lib/PhutilBootloader.php b/src/init/lib/PhutilBootloader.php
--- a/src/init/lib/PhutilBootloader.php
+++ b/src/init/lib/PhutilBootloader.php
@@ -207,6 +207,10 @@
$this->executeInclude($path);
}
+ public function loadLibrary($path) {
+ $this->executeInclude($path.'/__phutil_library_init__.php');
+ }
+
private function executeInclude($path) {
// Include the source using `include_once`, but convert any warnings or
// recoverable errors into exceptions.
diff --git a/src/init/lib/moduleutils.php b/src/init/lib/moduleutils.php
--- a/src/init/lib/moduleutils.php
+++ b/src/init/lib/moduleutils.php
@@ -49,5 +49,5 @@
}
function phutil_load_library($path) {
- require_once $path.'/__phutil_library_init__.php';
+ PhutilBootloader::getInstance()->loadLibrary($path);
}
diff --git a/src/runtime/ArcanistRuntime.php b/src/runtime/ArcanistRuntime.php
--- a/src/runtime/ArcanistRuntime.php
+++ b/src/runtime/ArcanistRuntime.php
@@ -410,7 +410,7 @@
if (!$resolved) {
$arcanist_root = phutil_get_library_root('arcanist');
- $arcanist_root = dirname($arcanist_root);
+ $arcanist_root = dirname(dirname($arcanist_root));
$resolved_location = Filesystem::resolvePath(
$location,
$arcanist_root);
@@ -427,23 +427,6 @@
$error = null;
try {
phutil_load_library($location);
- } catch (PhutilBootloaderException $ex) {
- fwrite(
- STDERR,
- '%s',
- tsprintf(
- "**<bg:red> %s </bg>** %s\n",
- pht(
- 'Failed to load phutil library at location "%s". This library '.
- 'is specified by "%s". Check that the setting is correct and '.
- 'the library is located in the right place.',
- $location,
- $description)));
-
- $prompt = pht('Continue without loading library?');
- if (!phutil_console_confirm($prompt)) {
- throw $ex;
- }
} catch (PhutilLibraryConflictException $ex) {
if ($ex->getLibrary() != 'arcanist') {
throw $ex;
@@ -462,19 +445,42 @@
// workflows more easily. For some context, see PHI13.
$executing_directory = dirname(dirname(__FILE__));
- $working_directory = dirname($location);
- fwrite(
- STDERR,
- tsprintf(
- "**<bg:yellow> %s </bg>** %s\n",
- pht('VERY META'),
- pht(
- 'You are running one copy of Arcanist (at path "%s") against '.
- 'another copy of Arcanist (at path "%s"). Code in the current '.
- 'working directory will not be loaded or executed.',
- $executing_directory,
- $working_directory)));
+ $log->writeWarn(
+ pht('VERY META'),
+ pht(
+ 'You are running one copy of Arcanist (at path "%s") against '.
+ 'another copy of Arcanist (at path "%s"). Code in the current '.
+ 'working directory will not be loaded or executed.',
+ $executing_directory,
+ $working_directory));
+ } catch (PhutilBootloaderException $ex) {
+ $log->writeError(
+ pht('LIBRARY ERROR'),
+ pht(
+ 'Failed to load library at location "%s". This library '.
+ 'is specified by "%s". Check that the library is up to date.',
+ $location,
+ $description));
+
+ $prompt = pht('Continue without loading library?');
+ if (!phutil_console_confirm($prompt)) {
+ throw $ex;
+ }
+ } catch (Exception $ex) {
+ $log->writeError(
+ pht('LOAD ERROR'),
+ pht(
+ 'Failed to load library at location "%s". This library is '.
+ 'specified by "%s". Check that the setting is correct and the '.
+ 'library is located in the right place.',
+ $location,
+ $description));
+
+ $prompt = pht('Continue without loading library?');
+ if (!phutil_console_confirm($prompt)) {
+ throw $ex;
+ }
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Mar 25, 8:01 AM (1 w, 20 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7714499
Default Alt Text
D21029.diff (3 KB)
Attached To
Mode
D21029: Improve error handling in ArcanistRuntime when failing to load libraries
Attached
Detach File
Event Timeline
Log In to Comment