You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2014/02/05 21:11:44 UTC
git commit: THRIFT-2349: Golang - improve tutorial
Updated Branches:
refs/heads/master 38b1a04b6 -> 56d41eb4a
THRIFT-2349: Golang - improve tutorial
Patch: Chris Bannister
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/56d41eb4
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/56d41eb4
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/56d41eb4
Branch: refs/heads/master
Commit: 56d41eb4a79148ff926f923426faddce6baaf3c4
Parents: 38b1a04
Author: Jens Geyer <je...@apache.org>
Authored: Wed Feb 5 21:10:59 2014 +0100
Committer: Jens Geyer <je...@apache.org>
Committed: Wed Feb 5 21:10:59 2014 +0100
----------------------------------------------------------------------
tutorial/go/src/client.go | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/56d41eb4/tutorial/go/src/client.go
----------------------------------------------------------------------
diff --git a/tutorial/go/src/client.go b/tutorial/go/src/client.go
index 31376f8..a497d7f 100644
--- a/tutorial/go/src/client.go
+++ b/tutorial/go/src/client.go
@@ -39,10 +39,13 @@ func handleClient(client *tutorial.CalculatorClient) (err error) {
work.Num2 = 0
quotient, err := client.Calculate(1, work)
if err != nil {
- fmt.Println("Error during operation:", err)
+ switch v := err.(type) {
+ case *tutorial.InvalidOperation:
+ fmt.Println("Invalid operation:", v)
+ default:
+ fmt.Println("Error during operation:", err)
+ }
return err
- //} else if ouch != nil {
- // fmt.Println("Invalid operation:", ouch)
} else {
fmt.Println("Whoa we can divide by 0 with new value:", quotient)
}
@@ -52,10 +55,13 @@ func handleClient(client *tutorial.CalculatorClient) (err error) {
work.Num2 = 10
diff, err := client.Calculate(1, work)
if err != nil {
- fmt.Println("Error during operation:", err)
+ switch v := err.(type) {
+ case *tutorial.InvalidOperation:
+ fmt.Println("Invalid operation:", v)
+ default:
+ fmt.Println("Error during operation:", err)
+ }
return err
- //} else if ouch != nil {
- // fmt.Println("Invalid operation:", ouch)
} else {
fmt.Print("15-10=", diff, "\n")
}