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