Java try catch and then what SneakyThrows

preview_player
Показать описание
Enjoy! :-)
Thank you for commenting and asking questions.

Library sign up referral link:

Checkout or buy the Introduction to Algorithms book at Amazon:

The code is located here:
Follow me on twitter:
Support me on Patreon:

As an Amazon Associate I earn from qualifying purchases.
Check out the stuff that I like (always updated):
Рекомендации по теме
Комментарии
Автор

Pretty cool annotation. I had no idea this existed. I agree that a lot of times code bases just have catch with an exception. Of course there are times where we handle the exception in a special way, but yeah, that's not always. The only issue I can see with sneaky throws is that if someone is implementing/using your method, they may not know that you may at times throw an exception, and they may not be prepared pre-emptively to handle the exception.

chadjensen
Автор

Hi Mike,
would it be okay if you can make more examples when we should use try/catch and what is the best approach?
You say that people usually throw the exception with another exception type or they don't do anything when catching!
Soo, if they don't do anything with that kind of exception they will still get some sort of exception, right?
It is just got confusing for me with the SneakyThrows annotation when you said that SneakyThrows is a good solution.
I just think that we would get the same exception even if we didn't use the SneakyThrow. Or am i wrong?
A little bit confusing, that's all!
I am working with a spring boot project where i use spring security JWT and in a method, i have to catch an exception and inside of that catch exception, i throw another exception to get some other methods executed.
I am always searching after good practices and i would appreciate it if you can explain it to me.
Thanks in advance!

fazlizekiqi
Автор

Thank you for the videos..
You deserve more subscribers ☺️
I would like to ask what would you suggest in case there is some error scenario is it okay to throw an exception and handle it in a global handler. Or returning a error response with proper message. I had done both in my earlier projects would like to know your opinion..

vishnumv