Skip to content

Commit dc987f2

Browse files
committed
Add --verbose flag to log output of failed response calls, etc
1 parent 0adf6a1 commit dc987f2

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

TODO.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
- Add tests on output (deterministic)
44
- Bring `bindings` outside of `response_calls`
55
- Should `routes.*.apply.response_calls.headers` be replaced by `routes.*.apply.headers`?
6-
- Implement debug flag

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"illuminate/console": "5.5.* || 5.6.* || 5.7.* || 5.8.*",
2323
"mpociot/documentarian": "^0.2.0",
2424
"mpociot/reflection-docblock": "^1.0.1",
25-
"ramsey/uuid": "^3.8"
25+
"ramsey/uuid": "^3.8",
26+
"nunomaduro/collision": "^3.0"
2627
},
2728
"require-dev": {
2829
"orchestra/testbench": "3.5.* || 3.6.* || 3.7.*",

src/Tools/ResponseStrategies/ResponseCallStrategy.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
use Illuminate\Routing\Route;
99
use Mpociot\ApiDoc\Tools\Flags;
1010
use Mpociot\ApiDoc\Tools\Utils;
11+
use NunoMaduro\Collision\Handler;
1112
use Mpociot\ApiDoc\Tools\Traits\ParamHelpers;
13+
use Whoops\Exception\Inspector;
1214

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

0 commit comments

Comments
 (0)