Skip to content

Commit

Permalink
Add --verbose flag to log output of failed response calls, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
shalvah committed Jun 23, 2019
1 parent 0adf6a1 commit dc987f2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 0 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
- Add tests on output (deterministic)
- Bring `bindings` outside of `response_calls`
- Should `routes.*.apply.response_calls.headers` be replaced by `routes.*.apply.headers`?
- Implement debug flag
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"illuminate/console": "5.5.* || 5.6.* || 5.7.* || 5.8.*",
"mpociot/documentarian": "^0.2.0",
"mpociot/reflection-docblock": "^1.0.1",
"ramsey/uuid": "^3.8"
"ramsey/uuid": "^3.8",
"nunomaduro/collision": "^3.0"
},
"require-dev": {
"orchestra/testbench": "3.5.* || 3.6.* || 3.7.*",
Expand Down
11 changes: 8 additions & 3 deletions src/Tools/ResponseStrategies/ResponseCallStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
use Illuminate\Routing\Route;
use Mpociot\ApiDoc\Tools\Flags;
use Mpociot\ApiDoc\Tools\Utils;
use NunoMaduro\Collision\Handler;
use Mpociot\ApiDoc\Tools\Traits\ParamHelpers;
use Whoops\Exception\Inspector;

/**
* Make a call to the route and retrieve its response.
Expand Down Expand Up @@ -37,11 +39,14 @@ public function __invoke(Route $route, array $tags, array $routeProps)
try {
$response = [$this->makeApiCall($request)];
} catch (\Exception $e) {
echo 'Response call failed for ['.implode(',', $route->methods)."] {$route->uri}";
echo 'Exception thrown during response call for ['.implode(',', $route->methods)."] {$route->uri}.\n";
if (Flags::$shouldBeVerbose) {
dump($e);
$handler = new Handler;
$handler->setInspector(new Inspector($e));
$handler->setException($e);
$handler->handle();
} else {
echo "Run this again with the --verbose flag for details";
echo "Run this again with the --verbose flag to see the exception.\n";
}
$response = null;
} finally {
Expand Down

0 comments on commit dc987f2

Please sign in to comment.