Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch guzzle exception and re-throw it with the full message #8

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 2 additions & 1 deletion src/DockerExecutorPhpServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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');
Expand Down
8 changes: 6 additions & 2 deletions src/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down