clearer title generation error message

fixes #329
This commit is contained in:
Jing Hua 2023-06-07 19:47:21 +08:00
parent 13ac535504
commit cb930e3e2c

View file

@ -23,6 +23,7 @@ const useSubmit = () => {
message: MessageInterface[]
): Promise<string> => {
let data;
try {
if (!apiKey || apiKey.length === 0) {
// official endpoint
if (apiEndpoint === officialAPIEndpoint) {
@ -44,6 +45,9 @@ const useSubmit = () => {
apiKey
);
}
} catch (error: unknown) {
throw new Error(`Error generating title!\n${(error as Error).message}`);
}
return data.choices[0].message.content;
};