digitalmars.D.learn - FileException vs. Exception
- jicman (22/22) Aug 18 2005 So, I have this function,
- Burton Radons (9/33) Aug 18 2005 That link you gave is for std.file - you're using std.stream.
- starkweatherr mchsi.com (2/2) Mar 20 2006 Where can I find the current definition of the FileException class, or w...
- Regan Heath (7/9) Mar 20 2006 I tend to use the find in files function in TextPad to scan
- Ben Hinkle (6/30) Aug 18 2005 FileException is in std.file. The exception thrown by std.stream.File.op...
So, I have this function,
|bit FileIsBusy(char[] fn)
|{
| File f = new File();
| try
| {
| f.open(fn);
| }
| catch (Exception e)
| {
| return(true);
| }
| f.close();
| return false;
|}
this work, however, if I change "Exception" for "FileException", it does not
work. if you go to,
http://www.digitalmars.com/d/phobos.html#file
you'll see that it's suppose to be a FileException. Is this correct? I don't
understand.
thanks,
josé
Aug 18 2005
jicman wrote:
So, I have this function,
|bit FileIsBusy(char[] fn)
|{
| File f = new File();
| try
| {
| f.open(fn);
| }
| catch (Exception e)
| {
| return(true);
| }
| f.close();
| return false;
|}
this work, however, if I change "Exception" for "FileException", it does not
work. if you go to,
http://www.digitalmars.com/d/phobos.html#file
you'll see that it's suppose to be a FileException. Is this correct? I don't
understand.
That link you gave is for std.file - you're using std.stream.
std.stream.File throws std.stream.OpenException when it can't
open/create a file.
One quick way to figure out what's going on is to do this:
catch (Object o)
{
printf("threw %.*s\n", o.classinfo.name);
}
Aug 18 2005
Where can I find the current definition of the FileException class, or whatever it is now?
Mar 20 2006
On Tue, 21 Mar 2006 00:07:21 +0000 (UTC), <starkweatherr mchsi.com> wrote:Where can I find the current definition of the FileException class, or whatever it is now?I tend to use the find in files function in TextPad to scan "dmd\src\phobos\" and all subdirectories for "*.d" containing the text I am after, in this case "FileException", results include: std\file.d(59): class FileException : Exception meaning dmd\src\phobos\std\file.d is the file you're after. Regan
Mar 20 2006
"jicman" <jicman_member pathlink.com> wrote in message
news:de2akv$2tk2$1 digitaldaemon.com...
So, I have this function,
|bit FileIsBusy(char[] fn)
|{
| File f = new File();
| try
| {
| f.open(fn);
| }
| catch (Exception e)
| {
| return(true);
| }
| f.close();
| return false;
|}
this work, however, if I change "Exception" for "FileException", it does
not
work. if you go to,
http://www.digitalmars.com/d/phobos.html#file
you'll see that it's suppose to be a FileException. Is this correct? I
don't
understand.
thanks,
josé
FileException is in std.file. The exception thrown by std.stream.File.open
is an OpenException, which subclasses StreamFileException (which subclasses
StreamException not FileException). I will document the exceptions thrown by
the stream classes and send the doc to Walter.
Aug 18 2005









"Regan Heath" <regan netwin.co.nz> 