@@ -77,13 +77,25 @@ protected function hasReplicaConfigurationChanged(string $primaryIndexName, int
77
77
}
78
78
}
79
79
80
- protected function getReplicaConfigurationFromAlgolia ($ primaryIndexName , bool $ refreshCache = false )
80
+ /**
81
+ * @param $primaryIndexName
82
+ * @param bool $refreshCache
83
+ * @return array<string, mixed>
84
+ * @throws LocalizedException
85
+ */
86
+ protected function getReplicaConfigurationFromAlgolia ($ primaryIndexName , bool $ refreshCache = false ): array
81
87
{
82
88
if ($ refreshCache || !isset ($ this ->_algoliaReplicaConfig [$ primaryIndexName ])) {
83
- $ currentSettings = $ this ->algoliaHelper ->getSettings ($ primaryIndexName );
84
- $ this ->_algoliaReplicaConfig [$ primaryIndexName ] = array_key_exists ('replicas ' , $ currentSettings )
85
- ? $ currentSettings ['replicas ' ]
86
- : [];
89
+ try {
90
+ $ currentSettings = $ this ->algoliaHelper ->getSettings ($ primaryIndexName );
91
+ $ this ->_algoliaReplicaConfig [$ primaryIndexName ] = array_key_exists ('replicas ' , $ currentSettings )
92
+ ? $ currentSettings ['replicas ' ]
93
+ : [];
94
+ } catch (\Exception $ e ) {
95
+ $ msg = "Unable to retrieve replica settings for $ primaryIndexName: " . $ e ->getMessage ();
96
+ $ this ->logger ->error ($ msg );
97
+ throw new LocalizedException (__ ($ msg ));
98
+ }
87
99
}
88
100
return $ this ->_algoliaReplicaConfig [$ primaryIndexName ];
89
101
}
@@ -103,6 +115,7 @@ protected function clearAlgoliaReplicaSettingCache($primaryIndexName = null): vo
103
115
*
104
116
* @param string $primaryIndexName
105
117
* @return string[]
118
+ * @throws LocalizedException
106
119
*/
107
120
protected function getMagentoReplicaConfigurationFromAlgolia (string $ primaryIndexName ): array
108
121
{
@@ -130,6 +143,7 @@ function ($algoliaReplicaSetting) use ($baseIndexName) {
130
143
/**
131
144
* @param string $primaryIndexName
132
145
* @return array
146
+ * @throws LocalizedException
133
147
*/
134
148
protected function getNonMagentoReplicaConfigurationFromAlgolia (string $ primaryIndexName ): array
135
149
{
0 commit comments