Generic Exception Handling in Service Layer RRS feed

  • Question

  • User-574293449 posted


    Before UI i have 2 layers now namely DAL(Core ado) and Service Layer(WCF REST). I am handling errors in service layer using Ihandler.

    I need to log the method name and class name which causes the error in the handleerror event.

    Example: I have a class named  'Class1DataAccess' in the DAL library. The class have one method name 'Method1'. In this method i didn't use any try ..catch. So automatically the error comes to service and i got the hanle error event.

    Here i need to log the class name here it is 'Class1DataAccess' and method name 'Method1'

    How to find this. In future may be business layer comes between these DAL and Service. Anyway i need to get the class name and method name which cause the error.

    I tried with StactTrace and StackFrame. But not yet helped which returns the internal class like mscorib .

    Can anyone help me


    Monday, February 3, 2014 11:48 PM

All replies

  • User1519735232 posted

    Hello, if you mean your client wants to do something different based on the exception type (BLL exception or other exceptions), you can return a generic FaultException from your service. For example, FaultException<BLLFault> and FaultException<GeneralFault>. With your code, you can modify your above ServiceFaultConverter ConvertExceptionToFaultDetail method to return different faults, instead of always returning ServiceFault.

    Friday, February 7, 2014 6:24 AM
  • User-574293449 posted

    Thats fine., But i need to log the acrtual error the source of the method which causes the error. For this pupose i need o get the which methd raise the error and the class name of the method included etc.

    Sunday, February 9, 2014 11:09 PM