Make error handling more robust

This commit is contained in:
Sander van der Burg 2022-02-19 01:20:43 +01:00
parent 37e4198762
commit 7ac17abdf2
7 changed files with 8 additions and 4 deletions

View file

@ -5,7 +5,7 @@
# To do this you need to vanilla composer package manager installed on your # To do this you need to vanilla composer package manager installed on your
# system. You can install composer from Nixpkgs as follows: # system. You can install composer from Nixpkgs as follows:
# #
# nix-env -f '<nixpkgs>' -iA php phpPackages.composer # nix-env -f '<nixpkgs>' -iA php phpPackages.composer nix-prefetch-scripts
composer install composer install
php bin/composer2nix --composer-env src/Composer2Nix/composer-env.nix --no-copy-composer-env --executable php bin/composer2nix --composer-env src/Composer2Nix/composer-env.nix --no-copy-composer-env --executable

View file

@ -1,5 +1,6 @@
<?php <?php
namespace Composer2Nix\Sources; namespace Composer2Nix\Sources;
use Exception;
use PNDP\NixGenerator; use PNDP\NixGenerator;
use PNDP\AST\NixExpression; use PNDP\AST\NixExpression;
use PNDP\AST\NixFunInvocation; use PNDP\AST\NixFunInvocation;
@ -30,7 +31,7 @@ class GitSource extends Source
{ {
$outputStr = shell_exec('nix-prefetch-git "'.$this->sourceObj['url'].'" '.$this->sourceObj["reference"]); $outputStr = shell_exec('nix-prefetch-git "'.$this->sourceObj['url'].'" '.$this->sourceObj["reference"]);
if($outputStr === false) if($outputStr === false || $outputStr === null)
throw new Exception("Error while invoking nix-prefetch-git"); throw new Exception("Error while invoking nix-prefetch-git");
else else
{ {

View file

@ -1,5 +1,6 @@
<?php <?php
namespace Composer2Nix\Sources; namespace Composer2Nix\Sources;
use Exception;
use PNDP\NixGenerator; use PNDP\NixGenerator;
use PNDP\AST\NixExpression; use PNDP\AST\NixExpression;
use PNDP\AST\NixFunInvocation; use PNDP\AST\NixFunInvocation;

View file

@ -1,5 +1,6 @@
<?php <?php
namespace Composer2Nix\Sources; namespace Composer2Nix\Sources;
use Exception;
use PNDP\NixGenerator; use PNDP\NixGenerator;
use PNDP\AST\NixExpression; use PNDP\AST\NixExpression;
use PNDP\AST\NixFunInvocation; use PNDP\AST\NixFunInvocation;

View file

@ -1,7 +1,7 @@
<?php <?php
namespace Composer2Nix\Sources; namespace Composer2Nix\Sources;
use PNDP\AST\NixASTNode;
use Exception; use Exception;
use PNDP\AST\NixASTNode;
/** /**
* Represents a dependency of a composer package that can be converted into a * Represents a dependency of a composer package that can be converted into a

View file

@ -1,5 +1,6 @@
<?php <?php
namespace Composer2Nix\Sources; namespace Composer2Nix\Sources;
use Exception;
use PNDP\NixGenerator; use PNDP\NixGenerator;
use PNDP\AST\NixExpression; use PNDP\AST\NixExpression;
use PNDP\AST\NixFile; use PNDP\AST\NixFile;

View file

@ -598,7 +598,7 @@ let
name = "svanderburg-php-sblayout-83d6d110494cdceb13da48a1acfa0ae989ba9ecd"; name = "svanderburg-php-sblayout-83d6d110494cdceb13da48a1acfa0ae989ba9ecd";
url = "https://github.com/svanderburg/php-sblayout.git"; url = "https://github.com/svanderburg/php-sblayout.git";
rev = "83d6d110494cdceb13da48a1acfa0ae989ba9ecd"; rev = "83d6d110494cdceb13da48a1acfa0ae989ba9ecd";
sha256 = null; sha256 = "1nxvppsxn6i4gczzmjlr50p94yw8v50s6l87qvpiyhh5162dyr3n";
}; };
}; };
"symfony/cache" = { "symfony/cache" = {