Skip to content

Instantly share code, notes, and snippets.

@bsideup
Last active August 29, 2015 14:18
Show Gist options
  • Save bsideup/130326357d8721b42b98 to your computer and use it in GitHub Desktop.
Save bsideup/130326357d8721b42b98 to your computer and use it in GitHub Desktop.
package com.example.calculator.handler;
-import com.example.calculator.*;
+import com.example.calculator.protocol.*;
+
import com.example.calculator.service.CalculatorService;
-import org.apache.thrift.TException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
-public class CalculatorServiceHandler implements TCalculatorService.Iface {
-
+public class CalculatorServiceHandler implements TCalculatorService {
+
@Autowired
CalculatorService calculatorService;
-
+
@Override
- public int calculate(int num1, int num2, TOperation op) throws TException {
+ public int calculate(int num1, int num2, TOperation op) throws TDivisionByZeroException {
switch(op) {
case ADD:
return calculatorService.add(num1, num2);
@@ -28,7 +28,7 @@ public class CalculatorServiceHandler implements TCalculatorService.Iface {
throw new TDivisionByZeroException();
}
default:
- throw new TException("Unknown operation " + op);
+ throw new IllegalArgumentException("Unknown operation " + op);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment