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); }