From d4c68522d46149d9744ec0a8e409f57d2701f63b Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Tue, 5 Nov 2013 12:32:55 +0100 Subject: [PATCH] improved error handling of AssetConverter issue #1140 --- framework/yii/views/errorHandler/exception.php | 2 +- framework/yii/views/errorHandler/previousException.php | 2 +- framework/yii/web/AssetConverter.php | 11 +++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/framework/yii/views/errorHandler/exception.php b/framework/yii/views/errorHandler/exception.php index 4b90de9..426447a 100644 --- a/framework/yii/views/errorHandler/exception.php +++ b/framework/yii/views/errorHandler/exception.php @@ -359,7 +359,7 @@ pre .diff .change{ } ?> -

htmlEncode($exception->getMessage()) ?>

+

htmlEncode($exception->getMessage())) ?>

renderPreviousExceptions($exception) ?> diff --git a/framework/yii/views/errorHandler/previousException.php b/framework/yii/views/errorHandler/previousException.php index 5e8ded8..766c0a7 100644 --- a/framework/yii/views/errorHandler/previousException.php +++ b/framework/yii/views/errorHandler/previousException.php @@ -15,7 +15,7 @@ htmlEncode(get_class($exception)) ?> -

htmlEncode($exception->getMessage()) ?>

+

htmlEncode($exception->getMessage())) ?>

in getFile() ?> at line getLine() ?>

renderPreviousExceptions($exception) ?> diff --git a/framework/yii/web/AssetConverter.php b/framework/yii/web/AssetConverter.php index 3b654e5..ba64aa9 100644 --- a/framework/yii/web/AssetConverter.php +++ b/framework/yii/web/AssetConverter.php @@ -9,6 +9,7 @@ namespace yii\web; use Yii; use yii\base\Component; +use yii\base\Exception; /** * AssetConverter supports conversion of several popular script formats into JS or CSS scripts. @@ -24,7 +25,7 @@ class AssetConverter extends Component implements AssetConverterInterface * target script types (either "css" or "js") and the commands used for the conversion. */ public $commands = [ - 'less' => ['css', 'lessc {from} {to}'], + 'less' => ['css', 'lessc {from} {to} --no-color'], 'scss' => ['css', 'sass {from} {to}'], 'sass' => ['css', 'sass {from} {to}'], 'styl' => ['js', 'stylus < {from} > {to}'], @@ -82,10 +83,12 @@ class AssetConverter extends Component implements AssetConverterInterface } $status = proc_close($proc); - if ($status !== 0) { - Yii::error("AssetConverter command '$command' failed with exit code $status:\nSTDOUT:\n$stdout\nSTDERR:\n$stderr\n"); - } else { + if ($status === 0) { Yii::trace("Converted $asset into $result:\nSTDOUT:\n$stdout\nSTDERR:\n$stderr", __METHOD__); + } elseif (YII_DEBUG) { + throw new Exception("AssetConverter command '$command' failed with exit code $status:\nSTDOUT:\n$stdout\nSTDERR:\n$stderr"); + } else { + Yii::error("AssetConverter command '$command' failed with exit code $status:\nSTDOUT:\n$stdout\nSTDERR:\n$stderr"); } return $status === 0; }