From af8769b5513ee642074e124a34c8b73a52a6c379 Mon Sep 17 00:00:00 2001 From: Nolan Ehrstrom Date: Tue, 16 Jun 2020 16:21:48 -0700 Subject: [PATCH] Catch guzzle exception and re-throw it with the full message --- composer.json | 2 +- src/DockerExecutorPhpServiceProvider.php | 3 ++- src/bootstrap.php | 8 ++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 3c8b2d0..d2c309a 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "processmaker/docker-executor-php", "friendly_name": "PHP Docker Executor", "description": "PHP script executor for processmaker 4", - "version": "1.0.0", + "version": "1.0.1", "minimum-stability": "dev", "license": "GAGPL-3.0-or-later", "autoload": { diff --git a/src/DockerExecutorPhpServiceProvider.php b/src/DockerExecutorPhpServiceProvider.php index 71b2c25..3efeaa6 100644 --- a/src/DockerExecutorPhpServiceProvider.php +++ b/src/DockerExecutorPhpServiceProvider.php @@ -10,7 +10,7 @@ class DockerExecutorPhpServiceProvider extends ServiceProvider { use PluginServiceProviderTrait; - const version = '1.0.0'; // Required for PluginServiceProviderTrait + const version = '1.0.1'; // Required for PluginServiceProviderTrait public function register() { @@ -28,6 +28,7 @@ public function boot() // Build the instance image. This is the same as if you were to build it from the admin UI \Artisan::call('processmaker:build-script-executor ' . $scriptExecutor->id); + $this->info(\Artisan::output()); // Restart the workers so they know about the new supported language // \Artisan::call('horizon:terminate'); diff --git a/src/bootstrap.php b/src/bootstrap.php index 0a52816..05eae6e 100644 --- a/src/bootstrap.php +++ b/src/bootstrap.php @@ -41,8 +41,12 @@ $api_config->setHost(getenv('API_HOST')); $api = new Executor\Api($api_config, isset($_ENV['API_SSL_VERIFY']) ? (bool) $_ENV['API_SSL_VERIFY'] : true); } - -$response = require(SCRIPT_PATH); +try { + $response = require(SCRIPT_PATH); +} catch(GuzzleHttp\Exception\ServerException $e) { + // Guzzle truncates by default so re-throw using full response + throw new \Exception(\GuzzleHttp\Psr7\str($e->getResponse())); +} // Finally store the output of our script into our output JSON path file_put_contents(OUTPUT_JSON_PATH, json_encode($response));