doubinduo3364 2015-10-22 14:50
浏览 78
已采纳

在PHP上使用DocBlocks,当我不处理execpetion错误时,我应该使用@throws吗?

I have a class for handling errors, and it is not using the try-throw-catch mechanism.

When I am commenting code that uses that class, should I use the the @throws tag even though I do not actually throwing anything?

EDIT (try to make my question more clear):

My question is if the @throws tags means that an error could occure when using the code and I am handling it in some way, or it means that an error could occure and I am handling it by using the throw keyword specifically?

  • 写回答

2条回答 默认 最新

  • douzhong6480 2015-10-22 19:18
    关注

    After reading the documentation, I realize that this is not exactly spelled out.

    The documentation on @throws suggests that if the throw keyword is present at all inside the block of code, then it should be documented for each type of exception that could be thrown regardless of whether or not you're handling it or not.

    So if you have

    try {
        throw new Exception();
    } catch (Exception $e) {
        // handled!
    }
    

    put a @throws entry in the docblock.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致