mirror of
https://github.com/manibatra/obsidian-text2anki-openai.git
synced 2026-07-22 07:40:28 +00:00
Better error handling
This commit is contained in:
parent
1db6ea57f8
commit
f3f8d546ff
1 changed files with 5 additions and 3 deletions
8
main.ts
8
main.ts
|
|
@ -205,7 +205,7 @@ export default class FlashcardGeneratorPlugin extends Plugin {
|
|||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
new Notice("An error occurred while adding card to deck");
|
||||
new Notice(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -220,10 +220,12 @@ export default class FlashcardGeneratorPlugin extends Plugin {
|
|||
}),
|
||||
});
|
||||
|
||||
const parsedResponse = await response.json();
|
||||
const parsedResponse = await response.json;
|
||||
|
||||
if (parsedResponse.hasOwnProperty("error")) {
|
||||
throw new Error(parsedResponse.error);
|
||||
if (parsedResponse.error !== null) {
|
||||
throw new Error(parsedResponse.error);
|
||||
}
|
||||
}
|
||||
|
||||
return parsedResponse.result;
|
||||
|
|
|
|||
Loading…
Reference in a new issue