@umituz/react-native-ai-generation-content 1.17.26 → 1.17.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -170,3 +170,31 @@ export function isTransientError(error: unknown): boolean {
|
|
|
170
170
|
export function isPermanentError(error: unknown): boolean {
|
|
171
171
|
return !isTransientError(error);
|
|
172
172
|
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Check if result is not ready yet (used during polling)
|
|
176
|
+
* More specific than isTransientError for result fetching scenarios
|
|
177
|
+
* Returns true for 404/not-found errors that indicate job still processing
|
|
178
|
+
*/
|
|
179
|
+
export function isResultNotReady(
|
|
180
|
+
error: unknown,
|
|
181
|
+
retryAttempt: number,
|
|
182
|
+
maxRetries: number,
|
|
183
|
+
): boolean {
|
|
184
|
+
if (isPermanentError(error)) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const message = error instanceof Error ? error.message.toLowerCase() : String(error).toLowerCase();
|
|
189
|
+
const errorName = error instanceof Error ? error.constructor.name.toLowerCase() : "";
|
|
190
|
+
|
|
191
|
+
return (
|
|
192
|
+
message.includes("not found") ||
|
|
193
|
+
message.includes("404") ||
|
|
194
|
+
message.includes("still in progress") ||
|
|
195
|
+
message.includes("result not ready") ||
|
|
196
|
+
message.includes("request is still in progress") ||
|
|
197
|
+
message.includes("job result not found") ||
|
|
198
|
+
(errorName === "apierror" && retryAttempt < maxRetries - 1)
|
|
199
|
+
);
|
|
200
|
+
}
|