Executing a line after which exception was thrown

A

Amit

A question i saw on 1 site

Is there a wayto put the control back to line after which the
exception occured

e.g.

try{
....

a.method() //line 6
a.doA() //line 7

... } (catch Exception e) {
}


Is it possible that an exception occured at line 6 and after catch i
want to resume execution from line 7 ??
 
E

ExGuardianReader

Amit said:
A question i saw on 1 site

Is there a wayto put the control back to line after which the
exception occured

e.g.

try{
...

a.method() //line 6
a.doA() //line 7

.. } (catch Exception e) {
}


Is it possible that an exception occured at line 6 and after catch i
want to resume execution from line 7 ??

??

try
{
a.method();
}
catch (TheMethodException e)
{
//handle it in an appropriate way.
}
a.doA();
 
M

Michael Rauscher

Amit said:
A question i saw on 1 site

Is there a wayto put the control back to line after which the
exception occured

e.g.

try{
...

a.method() //line 6
a.doA() //line 7

.. } (catch Exception e) {
}


Is it possible that an exception occured at line 6 and after catch i
want to resume execution from line 7 ??

Yes, but not this way. What you'd have to do is something like

try {
...
try {
a.method();
}
catch ( Exception innerException ) {
// handle exception
}
a.doA();
// ...
}
catch ( Exception outerException ) {
// handle exception
}

Bye
Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top