Home All Groups Group Topic Archive Search About
Author
1 Jun 2005 11:38 AM
Jefe
Hi guyz
I wonder whether it's better to raise an error with a custom error number or
set the err.number to that custom error number and then raise error I mean:
1 - Err.Number = 123456
     Err.Raise Err.Number
2 - Err.Raise 123456
well which one is better and why?
thanx alot

Author
1 Jun 2005 12:50 PM
Tony Proctor
Err.Raise <number> is the correct way. This sets Err.Number for you

I wouldn't recommend modifying any of the Err properties manually -- use
Err.Raise to set them, and Err.Clear to clear them down. You may notice that
Err.LastDllError is read-only anyway.

Also, on your Err.raise statement, you must set a 'source' and 'description'
for user-defined errors, otherwise you'll incur an 'Automation error' or
'Application-defined Error', e.g.

    Err.Raise 11                    ' OK since using the pre-defined code
for "Division by zero"

                                            'Using a user-defined error code
    Const lErrCode As Long = vbObjectError OR 1000
    Err.Raise lErrCode , "MyClass", "MyErrorMessage"


            Tony Proctor

Show quoteHide quote
"Jefe" <J***@discussions.microsoft.com> wrote in message
news:8DCC2C1F-4AD2-4EBA-A88A-C3325EA5203A@microsoft.com...
> Hi guyz
> I wonder whether it's better to raise an error with a custom error number
or
> set the err.number to that custom error number and then raise error I
mean:
> 1 - Err.Number = 123456
>      Err.Raise Err.Number
> 2 - Err.Raise 123456
> well which one is better and why?
> thanx alot
Are all your drivers up to date? click for free checkup

Author
1 Jun 2005 1:25 PM
Jefe
well why you wouldn't recommend modifying Err properties manually?

Show quoteHide quote
"Tony Proctor" wrote:

> Err.Raise <number> is the correct way. This sets Err.Number for you
>
> I wouldn't recommend modifying any of the Err properties manually -- use
> Err.Raise to set them, and Err.Clear to clear them down. You may notice that
> Err.LastDllError is read-only anyway.
>
> Also, on your Err.raise statement, you must set a 'source' and 'description'
> for user-defined errors, otherwise you'll incur an 'Automation error' or
> 'Application-defined Error', e.g.
>
>     Err.Raise 11                    ' OK since using the pre-defined code
> for "Division by zero"
>
>                                             'Using a user-defined error code
>     Const lErrCode As Long = vbObjectError OR 1000
>     Err.Raise lErrCode , "MyClass", "MyErrorMessage"
>
>
>             Tony Proctor
>
> "Jefe" <J***@discussions.microsoft.com> wrote in message
> news:8DCC2C1F-4AD2-4EBA-A88A-C3325EA5203A@microsoft.com...
> > Hi guyz
> > I wonder whether it's better to raise an error with a custom error number
> or
> > set the err.number to that custom error number and then raise error I
> mean:
> > 1 - Err.Number = 123456
> >      Err.Raise Err.Number
> > 2 - Err.Raise 123456
> > well which one is better and why?
> > thanx alot
>
>
>
Author
1 Jun 2005 1:39 PM
Tony Proctor
Because it's unnecessary, and misleading. Poking an error code into
Err.Number doesn't imply that an error has been raised anywhere

        Tony Proctor

Show quoteHide quote
"Jefe" <J***@discussions.microsoft.com> wrote in message
news:24B54C8C-2BDA-46D3-9346-FFFD5FF8A633@microsoft.com...
> well why you wouldn't recommend modifying Err properties manually?
>
> "Tony Proctor" wrote:
>
> > Err.Raise <number> is the correct way. This sets Err.Number for you
> >
> > I wouldn't recommend modifying any of the Err properties manually -- use
> > Err.Raise to set them, and Err.Clear to clear them down. You may notice
that
> > Err.LastDllError is read-only anyway.
> >
> > Also, on your Err.raise statement, you must set a 'source' and
'description'
> > for user-defined errors, otherwise you'll incur an 'Automation error' or
> > 'Application-defined Error', e.g.
> >
> >     Err.Raise 11                    ' OK since using the pre-defined
code
> > for "Division by zero"
> >
> >                                             'Using a user-defined error
code
> >     Const lErrCode As Long = vbObjectError OR 1000
> >     Err.Raise lErrCode , "MyClass", "MyErrorMessage"
> >
> >
> >             Tony Proctor
> >
> > "Jefe" <J***@discussions.microsoft.com> wrote in message
> > news:8DCC2C1F-4AD2-4EBA-A88A-C3325EA5203A@microsoft.com...
> > > Hi guyz
> > > I wonder whether it's better to raise an error with a custom error
number
> > or
> > > set the err.number to that custom error number and then raise error I
> > mean:
> > > 1 - Err.Number = 123456
> > >      Err.Raise Err.Number
> > > 2 - Err.Raise 123456
> > > well which one is better and why?
> > > thanx alot
> >
> >
> >

Bookmark and Share