1
0
mirror of https://github.com/aclindsa/ofxgo.git synced 2024-12-25 22:43:21 -05:00

Add status code meanings to status code error messages

This commit is contained in:
Aaron Lindsay 2017-03-25 06:14:52 -04:00
parent 3c56e60a85
commit 896bd55327
4 changed files with 12 additions and 8 deletions

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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)

View File

@ -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)
}