Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

intercept versus try/catch

I'm converting scala 'try/catch' testing code to use 'intercept'

Are there any scenarios where I should not use 'intercept' ? The only benefit of using 'intercept' instead of 'try/catch' is conciseness ?

like image 876
blue-sky Avatar asked Dec 06 '22 10:12

blue-sky


1 Answers

I think the main difference is that intercept has a semantic that the exception you got is expected, and not cause by program error.

So I normally only use intercept when the test case it to test exception will throw correctly when user input it incorrect or similar scenarios.

like image 160
Brian Hsu Avatar answered Dec 30 '22 10:12

Brian Hsu