From 03b79d8c4ad5e6146244c7aef28af3f0f9471fcd Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Wed, 20 Sep 2017 20:13:01 -0400 Subject: [PATCH] imports: Add better error reporting --- imports.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/imports.go b/imports.go index f8374ba..40a932a 100644 --- a/imports.go +++ b/imports.go @@ -114,12 +114,14 @@ func ofxImportHelper(r io.Reader, w http.ResponseWriter, user *User, accountid i if split.AccountId != importedAccount.AccountId { sqltransaction.Rollback() WriteError(w, 999 /*Internal Error*/) + log.Print("Imported split's AccountId wasn't -1 but also didn't match the account") return } split.AccountId = account.AccountId } else if split.SecurityId != -1 { if sec, ok := securitymap[split.SecurityId]; ok { split.SecurityId = sec.SecurityId + // TODO try to auto-match splits to existing accounts based on past transactions that look like this one } else { sqltransaction.Rollback() WriteError(w, 999 /*Internal Error*/) @@ -225,6 +227,7 @@ func ofxImportHelper(r io.Reader, w http.ResponseWriter, user *User, accountid i if err != nil { WriteError(w, 999 /*Internal Error*/) log.Print(err) + return } } @@ -343,6 +346,7 @@ func OFXImportHandler(w http.ResponseWriter, r *http.Request, user *User, accoun if err != nil { // TODO this could be an error talking with the OFX server... WriteError(w, 3 /*Invalid Request*/) + log.Print(err) return } defer response.Body.Close() @@ -362,6 +366,7 @@ func OFXFileImportHandler(w http.ResponseWriter, r *http.Request, user *User, ac if err != nil { if err == io.EOF { WriteError(w, 3 /*Invalid Request*/) + log.Print("Encountered unexpected EOF") } else { WriteError(w, 999 /*Internal Error*/) log.Print(err)