diff options
author | Jens Geyer <jensg@apache.org> | 2014-02-04 23:56:39 +0100 |
---|---|---|
committer | Jens Geyer <jensg@apache.org> | 2014-02-04 23:56:39 +0100 |
commit | 38b1a04b60f1122d94b8e83243f67a9c93182456 (patch) | |
tree | c2bb1f3d39d1b81d59c377e12cab631469dabcb3 /tutorial | |
parent | 4904ab81ff8f73b9a22872b5fb0ba2213597f2f2 (diff) | |
download | thrift-38b1a04b60f1122d94b8e83243f67a9c93182456.tar.gz |
THRIFT-2343 Fix tutotial code and codegen for methods without exceptions
Patch: Jens Geyer
Diffstat (limited to 'tutorial')
-rw-r--r-- | tutorial/go/src/client.go | 14 | ||||
-rw-r--r-- | tutorial/go/src/handler.go | 10 | ||||
-rw-r--r-- | tutorial/go/src/server.go | 2 |
3 files changed, 14 insertions, 12 deletions
diff --git a/tutorial/go/src/client.go b/tutorial/go/src/client.go index 543d7fb4e..31376f8f3 100644 --- a/tutorial/go/src/client.go +++ b/tutorial/go/src/client.go @@ -20,10 +20,10 @@ package main */ import ( + "crypto/tls" "fmt" "git.apache.org/thrift.git/lib/go/thrift" "tutorial" - "crypto/tls" ) func handleClient(client *tutorial.CalculatorClient) (err error) { @@ -37,12 +37,12 @@ func handleClient(client *tutorial.CalculatorClient) (err error) { work.Op = tutorial.Operation_DIVIDE work.Num1 = 1 work.Num2 = 0 - quotient, ouch, err := client.Calculate(1, work) + quotient, err := client.Calculate(1, work) if err != nil { fmt.Println("Error during operation:", err) return err - } else if ouch != nil { - fmt.Println("Invalid operation:", ouch) + //} else if ouch != nil { + // fmt.Println("Invalid operation:", ouch) } else { fmt.Println("Whoa we can divide by 0 with new value:", quotient) } @@ -50,12 +50,12 @@ func handleClient(client *tutorial.CalculatorClient) (err error) { work.Op = tutorial.Operation_SUBTRACT work.Num1 = 15 work.Num2 = 10 - diff, ouch, err := client.Calculate(1, work) + diff, err := client.Calculate(1, work) if err != nil { fmt.Println("Error during operation:", err) return err - } else if ouch != nil { - fmt.Println("Invalid operation:", ouch) + //} else if ouch != nil { + // fmt.Println("Invalid operation:", ouch) } else { fmt.Print("15-10=", diff, "\n") } diff --git a/tutorial/go/src/handler.go b/tutorial/go/src/handler.go index 3d4c18cee..fb0daef8c 100644 --- a/tutorial/go/src/handler.go +++ b/tutorial/go/src/handler.go @@ -44,7 +44,7 @@ func (p *CalculatorHandler) Add(num1 int32, num2 int32) (retval17 int32, err err return num1 + num2, nil } -func (p *CalculatorHandler) Calculate(logid int32, w *tutorial.Work) (val int32, ouch *tutorial.InvalidOperation, err error) { +func (p *CalculatorHandler) Calculate(logid int32, w *tutorial.Work) (val int32, err error) { fmt.Print("calculate(", logid, ", {", w.Op, ",", w.Num1, ",", w.Num2, "})\n") switch w.Op { case tutorial.Operation_ADD: @@ -58,17 +58,19 @@ func (p *CalculatorHandler) Calculate(logid int32, w *tutorial.Work) (val int32, break case tutorial.Operation_DIVIDE: if w.Num2 == 0 { - ouch = tutorial.NewInvalidOperation() + ouch := tutorial.NewInvalidOperation() ouch.What = int32(w.Op) ouch.Why = "Cannot divide by 0" + err = ouch return } val = w.Num1 / w.Num2 break default: - ouch = tutorial.NewInvalidOperation() + ouch := tutorial.NewInvalidOperation() ouch.What = int32(w.Op) ouch.Why = "Unknown operation" + err = ouch return } entry := shared.NewSharedStruct() @@ -84,7 +86,7 @@ func (p *CalculatorHandler) Calculate(logid int32, w *tutorial.Work) (val int32, } */ p.log[k] = entry - return val, ouch, err + return val, err } func (p *CalculatorHandler) GetStruct(key int32) (*shared.SharedStruct, error) { diff --git a/tutorial/go/src/server.go b/tutorial/go/src/server.go index ebcfe5bed..e4c4b9707 100644 --- a/tutorial/go/src/server.go +++ b/tutorial/go/src/server.go @@ -20,10 +20,10 @@ package main */ import ( + "crypto/tls" "fmt" "git.apache.org/thrift.git/lib/go/thrift" "tutorial" - "crypto/tls" ) func runServer(transportFactory thrift.TTransportFactory, protocolFactory thrift.TProtocolFactory, addr string, secure bool) error { |