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
$ hotfix pastebin:1234abcd
Downloading hotfix...
Checking signature...
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
$ hotfix apply pastebin:1234abcd
$ hotfix apply gist:user/hash
$ hotfix apply http://some.site/url.to.fix
### Applying local patches
$ hotfix apply --unsigned test.hotfix
Skipping signature check of test.hotfix
Info:
...
$ hotfix apply --insecure test.hotfix
### 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>");
return;
}
if (!$hotfix) {
$output->writeln("<error>Could not load hotfix</error>");
return;
}
$output->writeln("");
if (($signer = $hotfix->getSignedBy())) {

View File

@ -21,7 +21,9 @@ class 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);
$header = Yaml::parse($header);

View File

@ -43,7 +43,7 @@ class Loader
}
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)

View File

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