From 896bd55327731a2f07b39316127189c87fe134b4 Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Sat, 25 Mar 2017 06:14:52 -0400 Subject: [PATCH] Add status code meanings to status code error messages --- cmd/ofx/banktransactions.go | 3 ++- cmd/ofx/cctransactions.go | 3 ++- cmd/ofx/get_accounts.go | 11 ++++++----- cmd/ofx/invtransactions.go | 3 ++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/cmd/ofx/banktransactions.go b/cmd/ofx/banktransactions.go index b239b86..b01cf01 100644 --- a/cmd/ofx/banktransactions.go +++ b/cmd/ofx/banktransactions.go @@ -52,7 +52,8 @@ func bankTransactions() { } if response.Signon.Status.Code != 0 { - fmt.Printf("Nonzero signon status with message: %s\n", response.Signon.Status.Message) + meaning, _ := response.Signon.Status.CodeMeaning() + fmt.Printf("Nonzero signon status (%d: %s) with message: %s\n", response.Signon.Status.Code, meaning, response.Signon.Status.Message) os.Exit(1) } diff --git a/cmd/ofx/cctransactions.go b/cmd/ofx/cctransactions.go index 6810a77..abbef81 100644 --- a/cmd/ofx/cctransactions.go +++ b/cmd/ofx/cctransactions.go @@ -48,7 +48,8 @@ func ccTransactions() { } if response.Signon.Status.Code != 0 { - fmt.Printf("Nonzero signon status with message: %s\n", response.Signon.Status.Message) + meaning, _ := response.Signon.Status.CodeMeaning() + fmt.Printf("Nonzero signon status (%d: %s) with message: %s\n", response.Signon.Status.Code, meaning, response.Signon.Status.Message) os.Exit(1) } diff --git a/cmd/ofx/get_accounts.go b/cmd/ofx/get_accounts.go index fb27048..14841ed 100644 --- a/cmd/ofx/get_accounts.go +++ b/cmd/ofx/get_accounts.go @@ -36,25 +36,26 @@ func getAccounts() { } query.Signup = append(query.Signup, &acctInfo) - signupResponse, err := client.Request(query) + response, err := client.Request(query) if err != nil { fmt.Println("Error requesting account information:", err) os.Exit(1) } - if signupResponse.Signon.Status.Code != 0 { - fmt.Printf("Nonzero signon status with message: %s\n", signupResponse.Signon.Status.Message) + if response.Signon.Status.Code != 0 { + meaning, _ := response.Signon.Status.CodeMeaning() + fmt.Printf("Nonzero signon status (%d: %s) with message: %s\n", response.Signon.Status.Code, meaning, response.Signon.Status.Message) os.Exit(1) } - if len(signupResponse.Signup) < 1 { + if len(response.Signup) < 1 { fmt.Println("No signup messages received") return } fmt.Println("\nFound the following accounts:\n") - if acctinfo, ok := signupResponse.Signup[0].(ofxgo.AcctInfoResponse); ok { + if acctinfo, ok := response.Signup[0].(ofxgo.AcctInfoResponse); ok { for _, acct := range acctinfo.AcctInfo { if acct.BankAcctInfo != nil { fmt.Printf("Bank Account:\n\tBankId: \"%s\"\n\tAcctId: \"%s\"\n\tAcctType: %s\n", acct.BankAcctInfo.BankAcctFrom.BankId, acct.BankAcctInfo.BankAcctFrom.AcctId, acct.BankAcctInfo.BankAcctFrom.AcctType) diff --git a/cmd/ofx/invtransactions.go b/cmd/ofx/invtransactions.go index 8b93f8d..a4c97ae 100644 --- a/cmd/ofx/invtransactions.go +++ b/cmd/ofx/invtransactions.go @@ -55,7 +55,8 @@ func invTransactions() { } if response.Signon.Status.Code != 0 { - fmt.Printf("Nonzero signon status with message: %s\n", response.Signon.Status.Message) + meaning, _ := response.Signon.Status.CodeMeaning() + fmt.Printf("Nonzero signon status (%d: %s) with message: %s\n", response.Signon.Status.Code, meaning, response.Signon.Status.Message) os.Exit(1) }