@@ -145,10 +145,8 @@ public function maskException(\Exception $exception)
145145 $ stackTrace
146146 );
147147 } else {
148- // Check if this is a client error based on message content
149- $ httpCode = ($ this ->isClientError ($ exception ))
150- ? WebapiException::HTTP_BAD_REQUEST
151- : WebapiException::HTTP_INTERNAL_ERROR ;
148+ // Check if this is a client error based on the exception type
149+ $ httpCode = $ this ->getClientErrorHttpCode ($ exception );
152150 $ message = $ exception ->getMessage ();
153151 $ code = $ exception ->getCode ();
154152 //if not in Dev mode, make sure the message and code is masked for unanticipated exceptions
@@ -172,13 +170,14 @@ public function maskException(\Exception $exception)
172170 }
173171
174172 /**
175- * Determine if an exception is a client error based on the exception type
173+ * Return the HTTP code for a client error based on the exception type
176174 *
177175 * @param \Exception $exception
178- * @return bool
176+ * @return int
179177 */
180- private function isClientError (\Exception $ exception )
178+ private function getClientErrorHttpCode (\Exception $ exception )
181179 {
180+ // Check if this is a client error based on the exception type
182181 if ($ exception instanceof \Zend_Db_Exception
183182 || $ exception instanceof \Zend_Db_Adapter_Exception
184183 || $ exception instanceof \Zend_Db_Statement_Exception
@@ -188,9 +187,9 @@ private function isClientError(\Exception $exception)
188187 || $ exception instanceof \UnexpectedValueException
189188 || $ exception instanceof \Magento \Framework \Search \Request \NonExistingRequestNameException
190189 ) {
191- return true ;
190+ return WebapiException:: HTTP_BAD_REQUEST ;
192191 }
193- return false ;
192+ return WebapiException:: HTTP_INTERNAL_ERROR ;
194193 }
195194
196195 /**
0 commit comments