File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -178,11 +178,23 @@ protected function shouldDisplayWarning(array $recommendationResponse): bool
178
178
!array_key_exists ('hits ' , $ recommendationResponse );
179
179
}
180
180
181
+ /**
182
+ * If there is no model on the index then a 404 error should be returned
183
+ * (which will cause the exception on the API call) because there is no model for that index
184
+ * However errors which say "Index does not exist" are cryptic
185
+ * This function serves to make this clearer to the user while also filtering out the possible
186
+ * "ObjectID does not exist" error which can occur if the model does not contain the test product
187
+ */
181
188
protected function getUserFriendlyRecommendApiErrorMessage (\Exception $ e ): string
182
189
{
183
190
$ msg = $ e ->getMessage ();
184
- if ($ e ->getCode () === 404 && !!preg_match ('/index.*does not exist/i ' , $ msg )) {
185
- $ msg = (string ) __ ("A trained model could not be found. " );
191
+ if ($ e ->getCode () === 404 ) {
192
+ if (!!preg_match ('/index.*does not exist/i ' , $ msg )) {
193
+ $ msg = (string ) __ ("A trained model could not be found. " );
194
+ }
195
+ if (!!preg_match ('/objectid does not exist/i ' , $ msg )) {
196
+ $ msg = (string ) __ ("Could not find test product in trained model. " );
197
+ }
186
198
}
187
199
return $ msg ;
188
200
}
You can’t perform that action at this time.
0 commit comments