mirror of
https://github.com/ankitects/anki.git
synced 2026-01-09 12:03:56 -05:00
Better error handling for typed_answer
This commit is contained in:
parent
75dd53dba8
commit
666e22ed42
1 changed files with 16 additions and 11 deletions
|
|
@ -448,17 +448,22 @@ impl crate::services::SchedulerService for Collection {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let typed_answer = typed_answer_parent_node.map(|field| {
|
let typed_answer = typed_answer_parent_node
|
||||||
let note = self.get_note(next_card.card.note_id.into()).unwrap();
|
.map(|field| -> Result<(String, String)> {
|
||||||
let notetype = self.get_notetype(note.notetype_id.into()).unwrap().unwrap();
|
let note = self.get_note(next_card.card.note_id.into())?;
|
||||||
let ord = notetype.get_field_ord(&field.1).unwrap();
|
let notetype = self
|
||||||
let mut correct = note.fields[ord].clone();
|
.get_notetype(note.notetype_id.into())?
|
||||||
if field.0.contains("cloze") {
|
.or_not_found(note.notetype_id)?;
|
||||||
correct = extract_cloze_for_typing(&correct, (ord + 1).try_into().unwrap())
|
let ord = notetype.get_field_ord(&field.1).or_not_found(field.1)?;
|
||||||
.to_string()
|
let mut correct = note.fields[ord].clone();
|
||||||
}
|
if field.0.contains("cloze") {
|
||||||
(field.0, correct)
|
correct =
|
||||||
});
|
extract_cloze_for_typing(&correct, (ord + 1).try_into().unwrap_or(0))
|
||||||
|
.to_string()
|
||||||
|
}
|
||||||
|
Ok((field.0, correct))
|
||||||
|
})
|
||||||
|
.transpose()?;
|
||||||
|
|
||||||
Ok(NextCardDataResponse {
|
Ok(NextCardDataResponse {
|
||||||
next_card: Some(NextCardData {
|
next_card: Some(NextCardData {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue