File tree Expand file tree Collapse file tree 5 files changed +11
-128
lines changed Expand file tree Collapse file tree 5 files changed +11
-128
lines changed Original file line number Diff line number Diff line change 1919 "symfony/messenger" : " 6.0.*" ,
2020 "symfony/proxy-manager-bridge" : " 6.0.*" ,
2121 "symfony/runtime" : " 6.0.*" ,
22- "symfony/serializer" : " 6.0.*" ,
2322 "symfony/uid" : " 6.0.*" ,
2423 "symfony/yaml" : " 6.0.*"
2524 },
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ public function onKernelException(ExceptionEvent $event)
1414 {
1515 }
1616
17- public static function getSubscribedEvents ()
17+ public static function getSubscribedEvents (): array
1818 {
1919 return [
2020 KernelEvents::EXCEPTION => 'onKernelException ' ,
Original file line number Diff line number Diff line change 88use Symfony \Component \HttpFoundation \Response ;
99use Symfony \Component \HttpKernel \Event \ExceptionEvent ;
1010use Symfony \Component \HttpKernel \Exception \HttpExceptionInterface ;
11- use Symfony \Component \Serializer \Encoder \JsonEncoder ;
12- use Symfony \Component \Serializer \Normalizer \ObjectNormalizer ;
13- use Symfony \Component \Serializer \Serializer ;
1411
1512class ExceptionListener
1613{
@@ -40,11 +37,14 @@ public function onKernelException(ExceptionEvent $event): void
4037
4138 public function exceptionToJson (\Throwable $ exception ): string
4239 {
43- // Испольузем Serializer для преобразования объекта в JSON
44- $ encoders = [new JsonEncoder ()];
45- $ normalizers = [new ObjectNormalizer ()];
46- $ serializer = new Serializer ($ normalizers , $ encoders );
47-
48- return $ serializer ->serialize ($ exception , 'json ' );
40+ return json_encode (
41+ [
42+ 'message ' => $ exception ->getMessage (),
43+ 'code ' => $ exception ->getCode (),
44+ 'file ' => $ exception ->getFile (),
45+ 'line ' => $ exception ->getLine (),
46+ 'trace ' => $ exception ->getTraceAsString (),
47+ ]
48+ );
4949 }
5050}
Original file line number Diff line number Diff line change 173173 "php-cs-fixer/diff": {
174174 "version": "v2.0.2"
175175 },
176- "phpdocumentor/reflection-common": {
177- "version": "2.2.0"
178- },
179- "phpdocumentor/reflection-docblock": {
180- "version": "5.3.0"
181- },
182- "phpdocumentor/type-resolver": {
183- "version": "1.6.0"
184- },
185176 "phpspec/prophecy": {
186177 "version": "v1.15.0"
187178 },
480471 "symfony/security-http": {
481472 "version": "v6.0.5"
482473 },
483- "symfony/serializer": {
484- "version": "v6.0.12"
485- },
486474 "symfony/service-contracts": {
487475 "version": "v3.0.0"
488476 },
506494 },
507495 "theseer/tokenizer": {
508496 "version": "1.2.1"
509- },
510- "webmozart/assert": {
511- "version": "1.10.0"
512497 }
513498}
You can’t perform that action at this time.
0 commit comments