File tree Expand file tree Collapse file tree 3 files changed +14
-1
lines changed
Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -75,8 +75,8 @@ public function render(): ResponseInterface
7575 'exception ' => (new ReflectionClass ($ exception ))->getShortName (),
7676 'message ' => $ message ,
7777 'url ' => h ($ url ),
78- 'error ' => $ exception ,
7978 'code ' => $ code ,
79+ 'error ' => $ exception ,
8080 ];
8181
8282 if ($ this ->error instanceof ValidationException) {
@@ -128,6 +128,8 @@ public function getError(): Throwable
128128 private function debugViewVars ($ exception , array $ viewVars ): array
129129 {
130130 if (!Configure::read ('debug ' )) {
131+ unset($ viewVars ['error ' ]);
132+
131133 return $ viewVars ;
132134 }
133135
Original file line number Diff line number Diff line change @@ -60,6 +60,9 @@ public function test_validation_exception(): void
6060 $ message = reset ($ violation ->messages );
6161 $ this ->assertEquals ('_empty ' , $ message ->rule );
6262 $ this ->assertEquals ('This field cannot be left empty ' , $ message ->message );
63+
64+ $ this ->assertTrue (isset ($ object ->trace ));
65+ $ this ->assertTrue (isset ($ object ->error ));
6366 }
6467
6568 public function test_validation_exception_with_cakephp_debug_off (): void
@@ -77,5 +80,6 @@ public function test_validation_exception_with_cakephp_debug_off(): void
7780 $ object = json_decode ($ body );
7881
7982 $ this ->assertFalse (isset ($ object ->trace ));
83+ $ this ->assertFalse (isset ($ object ->error ));
8084 }
8185}
Original file line number Diff line number Diff line change 33
44namespace MixerApi \ExceptionRender \Test \App \Controller ;
55
6+ use Cake \Http \Exception \InternalErrorException ;
7+
68class ActorsController extends AppController
79{
810 /**
@@ -106,4 +108,9 @@ public function delete($id = null)
106108 }
107109 throw new \Exception ("Record not deleted " );
108110 }
111+
112+ public function exception ()
113+ {
114+ throw new InternalErrorException ('testing ' );
115+ }
109116}
You can’t perform that action at this time.
0 commit comments