Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Intl] Added exception handler to command line scripts #11914

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 12, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 30 additions & 6 deletions 36 src/Symfony/Component/Intl/Resources/bin/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

define('LINE_WIDTH', 75);

define('LINE', str_repeat('-', LINE_WIDTH) . "\n");
define('LINE', str_repeat('-', LINE_WIDTH)."\n");

function bailout($message)
{
echo wordwrap($message, LINE_WIDTH) . " Aborting.\n";
echo wordwrap($message, LINE_WIDTH)." Aborting.\n";

exit(1);
}
Expand All @@ -31,7 +31,7 @@ function centered($text)
{
$padding = (int) ((LINE_WIDTH - strlen($text))/2);

return str_repeat(' ', $padding) . $text;
return str_repeat(' ', $padding).$text;
}

function cd($dir)
Expand All @@ -47,18 +47,18 @@ function run($command)

if (0 !== $status) {
$output = implode("\n", $output);
echo "Error while running:\n " . getcwd() . '$ ' . $command . "\nOutput:\n" . LINE . "$output\n" . LINE;
echo "Error while running:\n ".getcwd().'$ '.$command."\nOutput:\n".LINE."$output\n".LINE;

bailout("\"$command\" failed.");
}
}

function get_icu_version_from_genrb($genrb)
{
exec($genrb . ' --version 2>&1', $output, $status);
exec($genrb.' --version 2>&1', $output, $status);

if (0 !== $status) {
bailout($genrb . ' failed.');
bailout($genrb.' failed.');
}

if (!preg_match('/ICU version ([\d\.]+)/', implode('', $output), $matches)) {
Expand All @@ -67,3 +67,27 @@ function get_icu_version_from_genrb($genrb)

return $matches[1];
}

set_exception_handler(function (\Exception $exception) {
echo "\n";

$cause = $exception;
$root = true;

while (null !== $cause) {
if (!$root) {
echo "Caused by\n";
}

echo get_class($cause).": ".$cause->getMessage()."\n";
echo "\n";
echo $cause->getFile().":".$cause->getLine()."\n";
foreach ($cause->getTrace() as $trace) {
echo $trace['file'].":".$trace['line']."\n";
}
echo "\n";

$cause = $cause->getPrevious();
$root = false;
}
});
Morty Proxy This is a proxified and sanitized view of the page, visit original site.