Merge pull request #2838 from SillyTavern/genraw-error-logging
Improve error handling of /genraw and /gen
This commit is contained in:
commit
854541f4ba
|
@ -3265,7 +3265,7 @@ export async function generateRaw(prompt, api, instructOverride, quietToLoud, sy
|
|||
}
|
||||
|
||||
if (data.error) {
|
||||
throw new Error(data.error);
|
||||
throw new Error(data.response);
|
||||
}
|
||||
|
||||
const message = cleanUpMessage(extractMessageFromData(data), false, false, true);
|
||||
|
@ -4413,9 +4413,9 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
|
|||
generatedPromptCache = '';
|
||||
|
||||
if (data?.response) {
|
||||
toastr.error(data.response, 'API Error');
|
||||
toastr.error(data.response, 'API Error', { preventDuplicates: true });
|
||||
}
|
||||
throw data?.response;
|
||||
throw new Error(data?.response);
|
||||
}
|
||||
|
||||
//const getData = await response.json();
|
||||
|
|
|
@ -2241,7 +2241,7 @@ function setEphemeralStopStrings(value) {
|
|||
async function generateRawCallback(args, value) {
|
||||
if (!value) {
|
||||
console.warn('WARN: No argument provided for /genraw command');
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
|
||||
// Prevent generate recursion
|
||||
|
@ -2260,12 +2260,16 @@ async function generateRawCallback(args, value) {
|
|||
setEphemeralStopStrings(resolveVariable(args?.stop));
|
||||
const result = await generateRaw(value, '', isFalseBoolean(args?.instruct), quietToLoud, systemPrompt, length);
|
||||
return result;
|
||||
} catch (err) {
|
||||
console.error('Error on /genraw generation', err);
|
||||
toastr.error(err.message, 'API Error', { preventDuplicates: true });
|
||||
} finally {
|
||||
if (lock) {
|
||||
activateSendButtons();
|
||||
}
|
||||
flushEphemeralStoppingStrings();
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2291,12 +2295,16 @@ async function generateCallback(args, value) {
|
|||
const name = args?.name;
|
||||
const result = await generateQuietPrompt(value, quietToLoud, false, '', name, length);
|
||||
return result;
|
||||
} catch (err) {
|
||||
console.error('Error on /gen generation', err);
|
||||
toastr.error(err.message, 'API Error', { preventDuplicates: true });
|
||||
} finally {
|
||||
if (lock) {
|
||||
activateSendButtons();
|
||||
}
|
||||
flushEphemeralStoppingStrings();
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -375,7 +375,9 @@ router.post('/generate', jsonParser, async function (request, response) {
|
|||
}
|
||||
}
|
||||
} catch (error) {
|
||||
let value = { error: true, status: error?.status, response: error?.statusText };
|
||||
const status = error?.status ?? error?.code ?? 'UNKNOWN';
|
||||
const text = error?.error ?? error?.statusText ?? error?.message ?? 'Unknown error on /generate endpoint';
|
||||
let value = { error: true, status: status, response: text };
|
||||
console.log('Endpoint error:', error);
|
||||
|
||||
if (!response.headersSent) {
|
||||
|
|
Loading…
Reference in New Issue