@@ -145,10 +145,8 @@ public function maskException(\Exception $exception)
145
145
$ stackTrace
146
146
);
147
147
} 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 );
152
150
$ message = $ exception ->getMessage ();
153
151
$ code = $ exception ->getCode ();
154
152
//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)
172
170
}
173
171
174
172
/**
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
176
174
*
177
175
* @param \Exception $exception
178
- * @return bool
176
+ * @return int
179
177
*/
180
- private function isClientError (\Exception $ exception )
178
+ private function getClientErrorHttpCode (\Exception $ exception )
181
179
{
180
+ // Check if this is a client error based on the exception type
182
181
if ($ exception instanceof \Zend_Db_Exception
183
182
|| $ exception instanceof \Zend_Db_Adapter_Exception
184
183
|| $ exception instanceof \Zend_Db_Statement_Exception
@@ -188,9 +187,9 @@ private function isClientError(\Exception $exception)
188
187
|| $ exception instanceof \UnexpectedValueException
189
188
|| $ exception instanceof \Magento \Framework \Search \Request \NonExistingRequestNameException
190
189
) {
191
- return true ;
190
+ return WebapiException:: HTTP_BAD_REQUEST ;
192
191
}
193
- return false ;
192
+ return WebapiException:: HTTP_INTERNAL_ERROR ;
194
193
}
195
194
196
195
/**
0 commit comments