www.digitalmars.com         C & C++   DMDScript  

D - exception handling

reply imr1984 <imr1984_member pathlink.com> writes:
in Handling Errors section in the spec, it doesnt show an example of using the
try catch finally keywords. Is it somewhere else? Surely that would be the right
place to put it.
Jan 13 2004
next sibling parent imr1984 <imr1984_member pathlink.com> writes:
In article <bu0dkg$1r5t$1 digitaldaemon.com>, imr1984 says...
in Handling Errors section in the spec, it doesnt show an example of using the
try catch finally keywords. Is it somewhere else? Surely that would be the right
place to put it.
can someone post an example for using the finally keyword, because C++ doesnt use it.
Jan 13 2004
prev sibling next sibling parent reply "Phill" <phill pacific.net.au> writes:
You should be able to implement a Singleton pattern
easy.
This is what I do in Java

public class One{
    One one;

public static void getOne(){
        if(one == null){
              new One();
            }
    }

private One(){ // private constructor
   //construct stuff
}

}

This way if there is an instance of One already
you cannot make another One.

This was good for me in Java because I found
that when clicking a JTable for some reason the
Thread goes through the event listener method
twice.

The Singleton pattern solved this problem for
me.


Phill.



"imr1984" <imr1984_member pathlink.com> wrote in message
news:bu0dkg$1r5t$1 digitaldaemon.com...
 in Handling Errors section in the spec, it doesnt show an example of using
the
 try catch finally keywords. Is it somewhere else? Surely that would be the
right
 place to put it.
Jan 13 2004
parent "Phill" <phill pacific.net.au> writes:
woops wrong thread!


"Phill" <phill pacific.net.au> wrote in message
news:bu20f7$1ff0$1 digitaldaemon.com...
 You should be able to implement a Singleton pattern
 easy.
 This is what I do in Java

 public class One{
     One one;

 public static void getOne(){
         if(one == null){
               new One();
             }
     }

 private One(){ // private constructor
    //construct stuff
 }

 }

 This way if there is an instance of One already
 you cannot make another One.

 This was good for me in Java because I found
 that when clicking a JTable for some reason the
 Thread goes through the event listener method
 twice.

 The Singleton pattern solved this problem for
 me.


 Phill.



 "imr1984" <imr1984_member pathlink.com> wrote in message
 news:bu0dkg$1r5t$1 digitaldaemon.com...
 in Handling Errors section in the spec, it doesnt show an example of
using
 the
 try catch finally keywords. Is it somewhere else? Surely that would be
the
 right
 place to put it.
Jan 13 2004
prev sibling parent J C Calvarese <jcc7 cox.net> writes:
imr1984 wrote:
 in Handling Errors section in the spec, it doesnt show an example of using the
 try catch finally keywords. Is it somewhere else? Surely that would be the
right
 place to put it.
I probably know less about error handling than you do, so my example may be of limited use (or wrong). But the attached example does compile and run and it may answer your question. If it doesn't help you, you might try to re-phrase your question. More specific questions get more specific answers. By the way, I'm assuming you've already looked at http://www.digitalmars.com/d/statement.html#try. (I agree it'd be nice to have an actual example in the documentation using these keywords.) -- Justin http://jcc_7.tripod.com/d/
Jan 13 2004