General methog for passing error information...

K

Kurt Hill

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
 
K

Kurt Hill

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!".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top