Improved error reporting

This commit is contained in:
Chris 2016-04-19 16:37:31 +02:00
parent 79bc0a92d9
commit fceb4c4966
5 changed files with 17 additions and 20 deletions

View File

@ -5,29 +5,16 @@ HotFix; Quickly patch and fix system
## Usage ## Usage
$ hotfix pastebin:1234abcd $ hotfix apply pastebin:1234abcd
Downloading hotfix... $ hotfix apply gist:user/hash
Checking signature... $ hotfix apply http://some.site/url.to.fix
Good signature from <bob@domain.com>
Info:
This hotfix will install this driver for you
Do you want to proceed?
Yes, No or Inspect [noi]: y
### Applying local patches ### Applying local patches
$ hotfix apply --unsigned test.hotfix $ hotfix apply --insecure test.hotfix
Skipping signature check of test.hotfix
Info:
...
### Signing ### Signing
$ hotfix sign -o test-signed.hotfix test.hotfix $ hotfix sign test.hotfix
...

View File

@ -40,6 +40,10 @@ class ApplyCommand extends Command
$output->writeln("<error>Error: ".$e->getMessage()."</error>"); $output->writeln("<error>Error: ".$e->getMessage()."</error>");
return; return;
} }
if (!$hotfix) {
$output->writeln("<error>Could not load hotfix</error>");
return;
}
$output->writeln(""); $output->writeln("");
if (($signer = $hotfix->getSignedBy())) { if (($signer = $hotfix->getSignedBy())) {

View File

@ -21,7 +21,9 @@ class Hotfix
protected function load($hotfix) protected function load($hotfix)
{ {
// echo $hotfix."\n\n"; if (strpos($hotfix, "\n---\n")===false) {
throw new \Exception("Hotfix is missing a proper header, is line endings wrong?");
}
list ($header, $body) = explode("\n---\n", $hotfix, 2); list ($header, $body) = explode("\n---\n", $hotfix, 2);
$header = Yaml::parse($header); $header = Yaml::parse($header);

View File

@ -43,7 +43,7 @@ class Loader
} }
return new Hotfix($body, $signer); return new Hotfix($body, $signer);
} }
fprintf(STDERR, "Error: Couldn't load '%s'", $fix); fprintf(STDERR, "Error: Couldn't load '%s'\n", $fix);
} }
protected function verifySignature($body, $signature) protected function verifySignature($body, $signature)

View File

@ -6,6 +6,10 @@ class HttpLoader implements LoaderInterface
{ {
public function load($fix) public function load($fix)
{ {
if (preg_match("/^http[s]?:/", $fix)) {
$body = file_get_contents($fix);
return $body;
}
return false; return false;
} }
} }