• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 通用異常處理框架(3)

    發表于:2014-04-28來源:博客園作者:風語者·疾風點擊數: 標簽:
    在這個默認的異常處理類的ProcessExeception方法中首先調用該類中處理日志記錄的方法,再根據配置中的ExReturnMode決定返回處理的結果方式,對異常進行處理

      在這個默認的異常處理類的ProcessExeception方法中首先調用該類中處理日志記錄的方法,再根據配置中的ExReturnMode決定返回處理的結果方式,對異常進行處理。特別是當設置為返回方式為Exception,即拋出異常對象時是先判斷該異常是否是最初發生的異常,還是已經處理包裝過的異常,避免重復處理異常(不管異常是來自本層或者其他層)。

      ExManagement.LogHandler包

      該包只有一個默認的DefaultLogHandler類,實現了ILogHandler接口,它負責把異常信息記錄到數據庫中。

      我的項目中使用的各層配置文件(示例)

      BusinessLogicLayer

    <ExManager ErrorCodeSource="DB" ConnectionString="Data Source=PDMDEV151.ITDEV.ZTE.COM.CN;user id=PDM;password=" DataTable="ErrorInfo">

    <ExHandler Name="BusinessLogicLayer" Type="ExManagement.Handler.DefaultExHandler, ExManagement.Handler" ReturnMode="Exception" AlertType="None"/>

    <LogHandler Type="ExManagement.LogHandler.DefaultLogHandler, ExManagement.LogHandler" ConnectionString="Data Source=PDMDEV151.ITDEV.ZTE.COM.CN;user id=PDM;password=" DataTable ="ExceptionLog"/>

    ExHandler>

    ExManager>

      配置意義為:根據ErrorId到數據庫ErrorInfo庫中獲取ErrorString,定義了一個ExHandler,名為BusinessLogicLayer的框架默認的異常處理類,異常返回方式為拋出異常對象,因為不是UI層,所以AlerType為None,該異常處理類用一個默認的LogHandler把異常日志記錄到數據庫ExceptionLog。

      BusinessFacadeLayer

    <ExManager ErrorCodeSource="DB" ConnectionString="Data Source=PDMDEV151.ITDEV.ZTE.COM.CN;user id=PDM;password=" DataBase="ErrorInfo">

    <ExHandler Name="BusinessFacadeLayer" Type="ExManagement.Handler.DefaultExHandler, ExManagement.Handler" ReturnMode="Exception" AlertType="None"/>

    <LogHandler Type="ExManagement.LogHandler.DefaultLogHandler, ExManagement.LogHandler" ConnectionString="Data Source=PDMDEV151.ITDEV.ZTE.COM.CN;user id=PDM;password=" DataTable ="ExceptionLog"/>

    ExHandler>

    ExManager>

      該層配置除ExHandler的Name不同外,與BusinessFacadeLayer的配置基本一致。

      WebUILayer

    <ExManager ErrorCodeSource="DB" ConnectionString="Data Source=PDMDEV151.ITDEV.ZTE.COM.CN;user id=PDM;password=" DataBase="ErrorInfo">

    <ExHandler Name="WebUILayer" Type="ExManagement.Handler.DefaultExHandler, ExManagement.Handler" ReturnMode="ExceptionString" AlertType="WebUI"/>

    <LogHandler Type="ExManagement.LogHandler.DefaultLogHandler, ExManagement.LogHandler" ConnectionString="Data Source=PDMDEV151.ITDEV.ZTE.COM.CN;user id=PDM;password=" DataTable ="ExceptionLog"/>

    ExHandler>

    ExManager>

      該層的異常處理器的ReturnMode方式為ExceptionString(即Exception.Message),彈出提示方式為WebUI。

      WinUILayer

    <ExManager ErrorCodeSource="DB" ConnectionString="Data Source=PDMDEV151.ITDEV.ZTE.COM.CN;user id=PDM;password=" DataBase="ErrorInfo">

    <ExHandler Name="WinUILayer" Type="ExManagement.Handler.DefaultExHandler, ExManagement.Handler" ReturnMode="ExceptionString" AlertType="WinUI"/>

    <LogHandler Type="ExManagement.LogHandler.DefaultLogHandler, ExManagement.LogHandler" ConnectionString="Data Source=PDMDEV151.ITDEV.ZTE.COM.CN;user id=PDM;password=" DataTable ="ExceptionLog"/>

    ExHandler>

    ExManager>

    原文轉自:http://kb.cnblogs.com/page/81682/

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>