From 299e94f592d07c08e5526bad4d8aee2394ed71ef Mon Sep 17 00:00:00 2001 From: Carlos Valencia Date: Tue, 4 Jun 2024 17:04:55 -0500 Subject: [PATCH] Adds error message management on generation --- src/lib/SunoApi.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/SunoApi.ts b/src/lib/SunoApi.ts index 528761a..de6306c 100644 --- a/src/lib/SunoApi.ts +++ b/src/lib/SunoApi.ts @@ -23,6 +23,7 @@ export interface AudioInfo { type?: string; tags?: string; // Genre of music. duration?: string; // Duration of the audio + error_message?: string; // Error message if any } class SunoApi { @@ -227,7 +228,10 @@ class SunoApi { const allCompleted = response.every( audio => audio.status === 'streaming' || audio.status === 'complete' ); - if (allCompleted) { + const allError = response.every( + audio => audio.status === 'error' + ); + if (allCompleted || allError) { return response; } lastResponse = response; @@ -358,6 +362,7 @@ class SunoApi { type: audio.metadata.type, tags: audio.metadata.tags, duration: audio.metadata.duration_formatted, + error_message: audio.metadata.error_message, })); }