Surface transcription proxy errors
This commit is contained in:
parent
c61345a89d
commit
196c6f48ed
@ -122,7 +122,10 @@ async function transcribeAudioFile(audioFile) {
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Transcription request failed with ${response.status}: ${JSON.stringify(payload)}`);
|
||||
return {
|
||||
status: response.status,
|
||||
body: payload,
|
||||
};
|
||||
}
|
||||
|
||||
const text = payload.text || payload.transcript || payload.output_text;
|
||||
|
||||
@ -102,6 +102,28 @@ function StatusPill({ status }: { status?: string }) {
|
||||
);
|
||||
}
|
||||
|
||||
function requestErrorMessage(error: unknown, fallback: string) {
|
||||
if (!axios.isAxiosError(error)) {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
const data = error.response?.data;
|
||||
|
||||
if (typeof data?.message === 'string') {
|
||||
return data.message;
|
||||
}
|
||||
|
||||
if (typeof data?.error === 'string') {
|
||||
return data.error;
|
||||
}
|
||||
|
||||
if (typeof data?.error?.message === 'string') {
|
||||
return data.error.message;
|
||||
}
|
||||
|
||||
return fallback;
|
||||
}
|
||||
|
||||
const emptyDraft: MemoryDraft = {
|
||||
title: '',
|
||||
ai_summary: '',
|
||||
@ -171,15 +193,7 @@ const SessionMemory = () => {
|
||||
});
|
||||
setNotice('Draft generated. Review and edit before saving.');
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError(error)) {
|
||||
setNotice(
|
||||
error.response?.data?.message ||
|
||||
error.response?.data?.error ||
|
||||
'Memory generation failed.',
|
||||
);
|
||||
} else {
|
||||
setNotice('Memory generation failed.');
|
||||
}
|
||||
setNotice(requestErrorMessage(error, 'Memory generation failed.'));
|
||||
} finally {
|
||||
setIsGenerating(false);
|
||||
}
|
||||
@ -206,15 +220,7 @@ const SessionMemory = () => {
|
||||
setTranscript(response.data.text || '');
|
||||
setNotice('Audio transcribed. Review the transcript before generating memory.');
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError(error)) {
|
||||
setNotice(
|
||||
error.response?.data?.message ||
|
||||
error.response?.data?.error ||
|
||||
'Audio transcription failed.',
|
||||
);
|
||||
} else {
|
||||
setNotice('Audio transcription failed.');
|
||||
}
|
||||
setNotice(requestErrorMessage(error, 'Audio transcription failed.'));
|
||||
} finally {
|
||||
setIsTranscribing(false);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user