-
-
Save bsideup/130326357d8721b42b98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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