Skip to content

Commit

Permalink
improve flare:test output
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Oct 11, 2021
1 parent 6d89c4c commit 71a1576
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"illuminate/support": "^7.0|^8.0",
"monolog/monolog": "^2.0",
"symfony/console": "^5.0",
"symfony/var-dumper": "^5.0"
"symfony/var-dumper": "^5.0",
"ext-curl": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.14",
Expand Down
40 changes: 38 additions & 2 deletions src/Commands/TestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

namespace Facade\Ignition\Commands;

use Composer\InstalledVersions;
use Exception;
use Facade\FlareClient\Flare;
use Facade\FlareClient\Http\Exceptions\BadResponse;
use Facade\FlareClient\Http\Exceptions\BadResponseCode;
use Illuminate\Config\Repository;
use Illuminate\Console\Command;
use Illuminate\Log\LogManager;
Expand Down Expand Up @@ -74,9 +77,42 @@ protected function sendTestException()

try {
app(Flare::class)->sendTestReport($testException);
$this->info(PHP_EOL);
$this->info('');
} catch (Exception $exception) {
$this->warn('❌ We were unable to send an exception to Flare. Make sure that your key is correct and that you have a valid subscription. '.PHP_EOL.PHP_EOL.'For more info visit the docs on installing Flare in a Laravel project: https://flareapp.io/docs/ignition-for-laravel/introduction');
$this->warn( '❌ We were unable to send an exception to Flare. ');

if ($exception instanceof BadResponseCode) {
$this->info('');
$message = 'Unknown error';

$body = $exception->response->getBody();

if (is_array($body) && isset($body['message'])) {
$message = $body['message'];
}

$this->warn("{$exception->response->getHttpResponseCode()} - {$message}");
} else {
$this->warn($exception->getMessage());
}

$this->warn('Make sure that your key is correct and that you have a valid subscription.');
$this->info('');
$this->info('For more info visit the docs on https://flareapp.io/docs/ignition-for-laravel/introduction');
$this->info('You can see the status page of Flare at https://status.flareapp.io');
$this->info('Flare support can be reached at support@flareapp.io');

$this->line('');
$this->line('Extra info');
$this->table([], [
['PHP version', phpversion()],
['facade/ignition', InstalledVersions::getVersion('facade/ignition')],
['facade/flare-client-php', InstalledVersions::getVersion('facade/flare-client-php')],
['Laravel version', app()->version()],
['Platform', PHP_OS],
['Curl', curl_version()['version']],
['SSL', curl_version()['ssl_version']],
]);

if ($this->output->isVerbose()) {
throw $exception;
Expand Down

0 comments on commit 71a1576

Please sign in to comment.