472,127 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

General methog for passing error information...

I am looking for a way to pass error information back from a COM+ object
that is "better" than incliding a byref argument in every single function...
The session object would be ideal, except for the fact that, well, it is the
session object and my lovewly idea would be broken if the user's browser
doesn't support cookies... But the idea would work like so:

'Stateless COM+ object:
public function DoSomethingReallyImportant(byval arg1 as long, byval arg2 as
long) as long
on error goto Panic
DoSomethingReallyImportant = arg1 / arg2

GetObjectContect.SetComplete
exit function

Panic:
GetObjectContext.SetAbort
if err.number = 11 'Divide by zero
Session("MyObject.ErrorMessage") = "Dufus! You can't divide by
zero... yet. The next generation Intel will be able to!"
else
GenerateBSOD()
end if

end function

The nice thing about this is that the error is available to the caller
if/when needed. I can't store it in a local variable in the component, as
the state info is lost at the setcomplete/setabort.

The only thing coming to mind is to include an "optional strError as
string" in EVERY SINGLE FUNCTION, which would be aggravating. I do not want
to use return values for dual purposes, either -- the only time I do that is
when returning a variant that should contain a value, but I use Null to
indicate an error. This let's me know there was an error, but not anything
else...

Any suggestions??

Kurt
Jul 19 '05 #1
2 1659
Have you considered raising the error again so that the caller can trap it?

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Kurt Hill" <ku******@pacbell.net> wrote in message
news:e%****************@tk2msftngp13.phx.gbl...
I am looking for a way to pass error information back from a COM+ object
that is "better" than incliding a byref argument in every single function... The session object would be ideal, except for the fact that, well, it is the session object and my lovewly idea would be broken if the user's browser
doesn't support cookies... But the idea would work like so:

'Stateless COM+ object:
public function DoSomethingReallyImportant(byval arg1 as long, byval arg2 as long) as long
on error goto Panic
DoSomethingReallyImportant = arg1 / arg2

GetObjectContect.SetComplete
exit function

Panic:
GetObjectContext.SetAbort
if err.number = 11 'Divide by zero
Session("MyObject.ErrorMessage") = "Dufus! You can't divide by
zero... yet. The next generation Intel will be able to!"
else
GenerateBSOD()
end if

end function

The nice thing about this is that the error is available to the caller
if/when needed. I can't store it in a local variable in the component, as the state info is lost at the setcomplete/setabort.

The only thing coming to mind is to include an "optional strError as
string" in EVERY SINGLE FUNCTION, which would be aggravating. I do not want to use return values for dual purposes, either -- the only time I do that is when returning a variant that should contain a value, but I use Null to
indicate an error. This let's me know there was an error, but not anything else...

Any suggestions??

Kurt

Jul 19 '05 #2
Mark,

No -- i'd have to use an a "resume next" and then place error trapping code
everywhere, and sometimes I'd rather have the page crash than proceed if I
forgot to check for an error...

And some of the "errors" or not crash-worthy -- they are informational, like
"You can't enter that event because you're too damn old!".

"Mark Schupp" <ms*****@ielearning.com> wrote in message
news:Og**************@TK2MSFTNGP12.phx.gbl...
Have you considered raising the error again so that the caller can trap it?
--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Kurt Hill" <ku******@pacbell.net> wrote in message
news:e%****************@tk2msftngp13.phx.gbl...
I am looking for a way to pass error information back from a COM+ object
that is "better" than incliding a byref argument in every single function...
The session object would be ideal, except for the fact that, well, it is

the
session object and my lovewly idea would be broken if the user's browser
doesn't support cookies... But the idea would work like so:

'Stateless COM+ object:
public function DoSomethingReallyImportant(byval arg1 as long, byval

arg2 as
long) as long
on error goto Panic
DoSomethingReallyImportant = arg1 / arg2

GetObjectContect.SetComplete
exit function

Panic:
GetObjectContext.SetAbort
if err.number = 11 'Divide by zero
Session("MyObject.ErrorMessage") = "Dufus! You can't divide by
zero... yet. The next generation Intel will be able to!"
else
GenerateBSOD()
end if

end function

The nice thing about this is that the error is available to the caller
if/when needed. I can't store it in a local variable in the component, as
the state info is lost at the setcomplete/setabort.

The only thing coming to mind is to include an "optional strError as
string" in EVERY SINGLE FUNCTION, which would be aggravating. I do not

want
to use return values for dual purposes, either -- the only time I do

that is
when returning a variant that should contain a value, but I use Null to
indicate an error. This let's me know there was an error, but not

anything
else...

Any suggestions??

Kurt


Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by stanley j Mroczek | last post: by
2 posts views Thread by SteveS | last post: by
7 posts views Thread by Ken Allen | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.