Source of file FilterException.php
Size: 1,725 Bytes - Last Modified: 2013-06-02T00:13:43+02:00
/home/theseer/Downloads/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Exception/FilterException.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 | <?php /* * This file is part of the Assetic package, an OpenSky project. * * (c) 2010-2013 OpenSky Project Inc * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Assetic\Exception; use Symfony\Component\Process\Process; /** * Describes an exception that occurred within a filter. * * @author Johannes M. Schmitt <schmittjoh@gmail.com> */ class FilterException extends \RuntimeException implements Exception { private $originalMessage; private $input; public static function fromProcess(Process $proc) { $message = sprintf("An error occurred while running:\n%s", $proc->getCommandLine()); $errorOutput = $proc->getErrorOutput(); if (!empty($errorOutput)) { $message .= "\n\nError Output:\n".str_replace("\r", '', $errorOutput); } $output = $proc->getOutput(); if (!empty($output)) { $message .= "\n\nOutput:\n".str_replace("\r", '', $output); } return new self($message); } public function __construct($message, $code = 0, \Exception $previous = null) { parent::__construct($message, $code, $previous); $this->originalMessage = $message; } public function setInput($input) { $this->input = $input; $this->updateMessage(); return $this; } public function getInput() { return $this->input; } private function updateMessage() { $message = $this->originalMessage; if (!empty($this->input)) { $message .= "\n\nInput:\n".$this->input; } $this->message = $message; } } |