how to ignore the custom exception?
In my application, I have made one custom exception.
Is there any way possible that, I can ignore it and continue the application running?
In my application, I have made one custom exception.
Is there any way possible that, I can ignore it and continue the application running?
Yes, quite possible. Depending on the logic, it might even be a good idea.
You use custom exceptions like regular exceptions (and if you're creating custom exceptions, this shouldn't come as news to you).
> In my application, I have made one custom exception.
>
>
> s there any way possible that, I can ignore it and
> continue the application running?
Why would you want to ignore it? If the exception occurs, something has gone wrong. You need to either handle it or bubble it up to the next layer.
My concern is that, I dont want to fail my application just because of any duplicate data, but want to throw the exception and ignore it.
but I dont know how to do that.
> My concern is that, I dont want to fail my
> application just because of any duplicate data, but
> want to throw the exception and ignore it.
So why throw it in the first place? Duplicate data throws an exception, but then you want to ignore it and allow duplicate data?
lets say, If i am reading student data from the file. And by mistake any student has entered the wrong data or same as other, So that is why I want to throw the exception.
But I dont want to terminate my application. So I can make sure that, i have wrong data but still I want to run the application.
> but want to throw the exception and ignore it.
Then don't throw the exception.
Throwing an exception and ignoring it is useless.
If you want e.g. to discard duplicate elements, do this in your code without throwing an exception.
You seem to be missing the point of exceptions. It's betime for me, and I don't really know how to explain it to you. This might help.
http://java.sun.com/docs/books/tutorial/essential/exceptions/index.html
Don't use exceptions to signal invalid input you can just as well check before processing it.
Otherwise, think about not only throwing but also catching your exception.