99namespace Opengento \WebapiLogger \Plugin ;
1010
1111use Magento \Framework \App \FrontControllerInterface ;
12+ use Magento \Framework \Webapi \Response as WebapiResponse ;
1213use Magento \Framework \App \RequestInterface ;
1314use Magento \Framework \Stdlib \DateTime \DateTime ;
1415use Magento \Webapi \Controller \Rest ;
@@ -42,9 +43,8 @@ public function beforeDispatch(FrontControllerInterface $subject, RequestInterfa
4243 public function afterDispatch (FrontControllerInterface $ subject , $ result , RequestInterface $ request ): mixed
4344 {
4445 if ($ this ->config ->isEnabled () && !$ request ->isXmlHttpRequest ()) {
45- $ exceptions = $ result ->getException ();
46-
47- if (!empty ($ exceptions )) {
46+ $ exceptions = $ result instanceof WebapiResponse::class ? $ result ->getException () : '' ;
47+ if ($ exceptions !== []) {
4848 $ responseCode = '' ;
4949 $ responseBody = '' ;
5050 foreach ($ exceptions as $ exception ) {
@@ -55,8 +55,7 @@ public function afterDispatch(FrontControllerInterface $subject, $result, Reques
5555 $ responseBody = rtrim ($ responseBody );
5656 } else {
5757 $ responseCode = (string )$ result ->getStatusCode ();
58- $ responseBody = $ result ->getContent ();
59- $ responseBody = trim ($ responseBody , '" ' );
58+ $ responseBody = trim ($ result ->getContent (), '" ' );
6059 }
6160
6261 $ this ->logHandle ->after ($ responseCode , $ responseBody , $ this ->date ->gmtDate ());
0 commit comments