Pārlūkot izejas kodu

Add --verbose flag to log output of failed response calls, etc

shalvah 5 gadi atpakaļ
vecāks
revīzija
dc987f296e
3 mainītis faili ar 10 papildinājumiem un 5 dzēšanām
  1. 0 1
      TODO.md
  2. 2 1
      composer.json
  3. 8 3
      src/Tools/ResponseStrategies/ResponseCallStrategy.php

+ 0 - 1
TODO.md

@@ -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

+ 2 - 1
composer.json

@@ -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.*",

+ 8 - 3
src/Tools/ResponseStrategies/ResponseCallStrategy.php

@@ -8,7 +8,9 @@ use Illuminate\Http\Response;
 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.
@@ -37,11 +39,14 @@ class ResponseCallStrategy
         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 {