From e834fbe31041d9225b767581048b3d574cc3b419 Mon Sep 17 00:00:00 2001 From: Ushitora Anqou Date: Sun, 15 Oct 2023 21:04:40 +0900 Subject: [PATCH] Handle account not found exception --- lib/sql_writer.ml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/sql_writer.ml b/lib/sql_writer.ml index 1e6247d..0e7ccc7 100644 --- a/lib/sql_writer.ml +++ b/lib/sql_writer.ml @@ -300,8 +300,12 @@ let dump_transaction_records_and_posting_records (model : Model.t) (tx.postings |> List.mapi (fun i (p : Model.posting) -> let ps_id = List.length ps_recs + i in + let account_name = list_last p.account in let acc_id = - account_id_map |> StringMap.find (list_last p.account) + try account_id_map |> StringMap.find account_name + with Not_found -> + failwith + (Printf.sprintf "account not found: %s" account_name) in (ps_id, acc_id, tx_id, Option.get p.amount, p.narration))) @ ps_recs