C
C
coden552016-07-30 08:33:58
Java
coden55, 2016-07-30 08:33:58

Pass additional data in an exception?

Is it possible to create your own CustomException and pass additional variables (int long etc) to it for processing in the catch block?
Is this practiced or should it be avoided?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Eugene, 2016-07-30
@zolt85

If you use such a CustomException exclusively inside your application, and your application does not have a public API through which such an exception can be thrown, then I see nothing wrong with using a CustomException.

E
Evhen, 2016-08-02
@EugeneP2

Can. That's what the exception object is for.

G
GavriKos, 2016-07-30
@GavriKos

This is best avoided

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question