Skip to content

Commit 8e7c819

Browse files
committed
MAGE-1201 Add clarity to missing index API errors
1 parent 1ee35fe commit 8e7c819

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Observer/RecommendSettings.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,21 @@ protected function validateRecommendation(string $changedPath, string $recommend
154154
throw new LocalizedException(__(
155155
"Unable to save %1 Recommend configuration due to the following error: %2",
156156
$modelName,
157-
$e->getMessage()
157+
$this->getUserFriendlyRecommendApiErrorMessage($e)
158158
)
159159
);
160160
}
161161
}
162162

163+
protected function getUserFriendlyRecommendApiErrorMessage(\Exception $e): string
164+
{
165+
$msg = $e->getMessage();
166+
if ($e->getCode() === 404 && !!preg_match('/index.*does not exist/i', $msg)) {
167+
$msg = (string) __("A trained model could not be found.");
168+
}
169+
return $msg;
170+
}
171+
163172
/**
164173
* @return string - Product ID string for use in API calls
165174
* @throws LocalizedException

0 commit comments

Comments
 (0)