Java, Catching an exception and passing it to a method -


i created method accepts ioexception argument. method opens out stream , prints information exception text file. problem seem running into.. how call method catch block?

try{     if(true)         throw new ioexception(); } catch(ioexception e){     //pass method } 

:::edit:::

public void logerrors(ioexception e){     printwriter out = yada yada;      out.println(e.getcause()); } 

basically have call name of method, want method's code executed this:

try{     if(true)         throw new ioexception(); } catch(ioexception e){     //pass method     methodtoexecute(e); }  also, can see throw ioexception in both cases perhaps  may want consider modifying code use block 

edit

on second thought, can use if statement throw always.

if (...) {    yourmethod(throw new ioexception()); } 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -