Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
August 18, 2005 FileException vs. Exception | ||||
---|---|---|---|---|
| ||||
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é |
August 18, 2005 Re: FileException vs. Exception | ||||
---|---|---|---|---|
| ||||
Posted in reply to jicman | 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);
}
|
August 18, 2005 Re: FileException vs. Exception | ||||
---|---|---|---|---|
| ||||
Posted in reply to jicman | "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. |
March 21, 2006 Re: FileException vs. Exception | ||||
---|---|---|---|---|
| ||||
Posted in reply to Burton Radons | Where can I find the current definition of the FileException class, or whatever it is now? |
March 21, 2006 Re: FileException vs. Exception | ||||
---|---|---|---|---|
| ||||
Posted in reply to starkweatherr | 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
|
Copyright © 1999-2021 by the D Language Foundation