• 请不要在回答技术问题时复制粘贴 AI 生成的内容
WhyAreYouSoSad
V2EX  ›  程序员

请教这样异常处理模块要怎么实现吗?

  •  
  •   WhyAreYouSoSad · Sep 1, 2016 · 2825 views
    This topic created in 3576 days ago, the information mentioned may be changed or developed.
    有没有哪种异常处理设计是只要继承某个类,我无需在子类的代码里 trycatch 就能把错误信息自动抛到那个父类里面去,我只需要改一改父类的那个处理细节,或者根据子类的需求自己重写处理细节。


    我重新简要的说一下。有没有一种设计是,我只需关注异常处理的细节实现,而无需关注异常的位置抓取。
    6 replies    2016-09-02 11:54:49 +08:00
    WhyAreYouSoSad
        1
    WhyAreYouSoSad  
    OP
       Sep 1, 2016
    没人理我,自己顶一下
    freelee
        2
    freelee  
       Sep 1, 2016
    是 java 么,感觉继承没法这么干吧
    要不就像 spring mvc 那样,所有都走处理先走 DispatcherServlet ,异常处理最后都可以在 DispatcherServlet 中处理
    a199261800
        3
    a199261800  
       Sep 1, 2016
    @freelee 无论是继承还是什么框架都好,目前用的是.net.
    WhyAreYouSoSad
        4
    WhyAreYouSoSad  
    OP
       Sep 1, 2016
    ????
    Rand01ph
        5
    Rand01ph  
       Sep 1, 2016
    Django 就是这样的实现
    SmiteChow
        6
    SmiteChow  
       Sep 2, 2016
    切面编程, decoretor
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3701 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 05:08 · PVG 13:08 · LAX 22:08 · JFK 01:08
    ♥ Do have faith in what you're doing.