diff --git a/README.md b/README.md index e07a5f3..4e3ea44 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,12 @@ new ExceptionApiProblem(new \Exception('message', 500)); "code": 500, "line": 23, "file": "exception.php", - "trace": "#0 [internal function]: ...", + "trace": [ + "#0 [internal function]: ...", + "#1 [internal function]: ...", + "#3 [internal function]: ...", + "..." + ], "previous": [ { "message": "previous", @@ -71,7 +76,12 @@ new ExceptionApiProblem(new \Exception('message', 500)); "code": 0, "line": 20, "file": "exception.php", - "trace": "#0 [internal function]: ..." + "trace": [ + "#0 [internal function]: ...", + "#1 [internal function]: ...", + "#3 [internal function]: ...", + "..." + ] } ] } diff --git a/spec/Http/ExceptionApiProblemSpec.php b/spec/Http/ExceptionApiProblemSpec.php index be96727..3ee61d3 100644 --- a/spec/Http/ExceptionApiProblemSpec.php +++ b/spec/Http/ExceptionApiProblemSpec.php @@ -70,7 +70,7 @@ public function it_can_parse_to_debuggable_array(): void 'code' => 500, 'line' => $exception->getLine(), 'file' => $exception->getFile(), - 'trace' => $exception->getTraceAsString(), + 'trace' => explode("\n", $exception->getTraceAsString()), 'previous' => [], ], ]); @@ -94,7 +94,7 @@ public function it_contains_flattened_previous_exceptions_in_debuggable_output() 'code' => 0, 'line' => $exception->getLine(), 'file' => $exception->getFile(), - 'trace' => $exception->getTraceAsString(), + 'trace' => explode("\n", $exception->getTraceAsString()), 'previous' => [ [ 'type' => Exception::class, @@ -102,7 +102,7 @@ public function it_contains_flattened_previous_exceptions_in_debuggable_output() 'code' => 2, 'line' => $previous->getLine(), 'file' => $previous->getFile(), - 'trace' => $previous->getTraceAsString(), + 'trace' => explode("\n", $previous->getTraceAsString()), ], [ 'type' => Exception::class, @@ -110,7 +110,7 @@ public function it_contains_flattened_previous_exceptions_in_debuggable_output() 'code' => 1, 'line' => $first->getLine(), 'file' => $first->getFile(), - 'trace' => $first->getTraceAsString(), + 'trace' => explode("\n", $first->getTraceAsString()), ], ], ], diff --git a/src/Http/ExceptionApiProblem.php b/src/Http/ExceptionApiProblem.php index 3074b01..a7c4829 100644 --- a/src/Http/ExceptionApiProblem.php +++ b/src/Http/ExceptionApiProblem.php @@ -56,7 +56,7 @@ private function serializeException(Throwable $throwable): array 'code' => $throwable->getCode(), 'line' => $throwable->getLine(), 'file' => $throwable->getFile(), - 'trace' => $throwable->getTraceAsString(), + 'trace' => explode("\n", $throwable->getTraceAsString()), ]; } }