Skip to content

Commit 522de3c

Browse files
author
jiannei
committed
feat: debug 关闭时返回简短的错误提示
1 parent 8a0d99e commit 522de3c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Support/Traits/ExceptionTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected function prepareJsonResponse($request, Throwable $e)
3535
return app(Response::class)->fail(
3636
'',
3737
$this->isHttpException($e) ? $e->getStatusCode() : 500,
38-
config('app.debug', false) ? $this->convertExceptionToArray($e) : [],
38+
$this->convertExceptionToArray($e),
3939
$this->isHttpException($e) ? $e->getHeaders() : [],
4040
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
4141
);

tests/FailTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function testFailOutController()
100100
$response = Response::fail(
101101
'',
102102
$this->isHttpException($httpException) ? $httpException->getStatusCode() : 500,
103-
config('app.debug', false) ? $this->convertExceptionToArray($httpException) : [],
103+
$this->convertExceptionToArray($httpException),
104104
$this->isHttpException($httpException) ? $httpException->getHeaders() : [],
105105
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
106106
);
@@ -109,8 +109,8 @@ public function testFailOutController()
109109
'status' => 'fail',
110110
'code' => ResponseCodeEnum::SYSTEM_ERROR,
111111
'message' => ResponseCodeEnum::fromValue(ResponseCodeEnum::SYSTEM_ERROR)->description,
112-
'data' => (object) [],
113-
'error' => config('app.debug', false) ? $this->convertExceptionToArray($httpException) : (object) [],
112+
'data' => (object) [],
113+
'error' => $this->convertExceptionToArray($httpException),
114114
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
115115

116116
$this->assertJsonStringEqualsJsonString($expectedJson, $response->getContent());

0 commit comments

Comments
 (0)