Re: Need help with ApplicationException

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Okay, I'm assuming that somewhere in this employee object stored in a
session variable is the "userid name." If so, and you're creating your own
custom Exception class (why are you inheriting ApplicationException instead
of Exception?), you can create a field named "userid" in the custom
Exception class, and implement a constructor method that includes the
"userid" as a parameter. Then in your Try/Catch (you ARE using Try/Catch,
aren't you???), you do something like the following:

catch (Exception ex)
{
throw new MyCustomException(ex.Message, ex,
((employee)Session["CurrentEmployee"]).userid);
}

Of course, what you do with your new Custom Exception is up to you, but I
hope you get the idea.
--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Everybody picks their nose,
But some people are better at hiding it.

"Charles" <Charles@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:D4BD738B-02BA-4E16-A5C8-238FEE2FA57A@xxxxxxxxxxxxxxxx
>I need to find a way to share information between two classes, one is an
> employee class and the other is a custom error class that inherits from
> ApplicationException. These two classes are part of a ClassLibrary
> project.
> The other project has all the web page classes.
>
> My project allows employees to log in using Forms Auth, I do some checking
> on the person that is logging in and then after that is good I create an
> employee object and that is stored in a session variable.
>
> What I would like is if this employee that logged in gets an error message
> at anytime during their use of the web site that the error gets logged
> with
> their userid name. I can log errors and all that, I am logging them to a
> database. What I need is just how do I get the error message with the
> userid
> name.
>
> Thanks,
> Charles
>


.



Relevant Pages

  • Re: Some questions about handling exceptions and when to throw them
    ... In the event that a customer can't be ... Possibly even my own exception, ... because the caller should have checked first. ... If GetEmployeeInfo fails, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Some questions about handling exceptions and when to throw them
    ... So in those cases throwing an exception would be a good decision. ... because the caller should have checked first. ... PrinterInfo GetEmployeeDefaultPrinter ... If GetEmployeeInfo fails, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Need help with ApplicationException
    ... Yes there is a "userid name" variable in the employee object. ... I am not sure why I am using ApplicationException instead of Exception. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Project5Read
    ... The Employee has 15 Vacation Days Available ... buffer may be lost when an exception is thrown. ...
    (comp.lang.java.help)
  • Re: *** Software Architect & Lead Openings @ Hyderabad
    ... You all are the exception rather than the rule. ... only job is to run defense for management and none are technically capable ... We cannot show you confidential company material until you are an employee. ...
    (comp.os.linux.embedded)