What is the better way to handle exceptions if I need to transfer them to UI.
What I need to use: throwing Checked/Unchecked(which from them is better) through several methods to UI to show to user an appropriate message or return error code from method to method to UI or maybe something else?
UPDATED:
Does it good idea to use Android ‘s Handler to handle all checked/unchecked (maybe only on of them) exceptions that I don’t know what to do with them in place where they appear?
for example
…
catch(NUllPointerException){
UIExceptionHandler.sendEmptyMessage(...);
}
…
onHandleMessage(...){
//handle exception here - for example show toast
}
?
I would personally create a custom exception and throw that all the way to the UI layer. That way, you’re not throwing all exceptions. You can catch all the other exceptions in the lower layers of your project, but when you’re at those areas that need to be brought back up the to UI, you catch the original exception and re-throw your custom one.