V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
ioioioioioioi
V2EX  ›  问与答

你们的 PHP 代码中,大量的使用 try catch 吗

  •  
  •   ioioioioioioi · Jun 29, 2020 · 2230 views
    This topic created in 2139 days ago, the information mentioned may be changed or developed.
    5 replies    2020-06-29 17:56:30 +08:00
    WytheHuang
        1
    WytheHuang  
       Jun 29, 2020
    看业务吧,但是公司大部分用 try catch 的
    myd
        2
    myd  
       Jun 29, 2020
    大量使用 return 0, 1, 2, -1, true, false
    lazypu
        3
    lazypu  
       Jun 29, 2020
    算有吧, 做接口, 有啥业务错误都抛出个自定义异常, 最外层接住给出响应.
    donieleigh
        4
    donieleigh  
       Jun 29, 2020
    利用 set_exception_handler 统一处理异常,比到处 try...catch 优雅,主流框架都有实现。
    caola
        5
    caola  
       Jun 29, 2020
    个人认为,在处理 mysql 事物的时候,还是使用 try...catch 比较方便……
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   968 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 46ms · UTC 20:16 · PVG 04:16 · LAX 13:16 · JFK 16:16
    ♥ Do have faith in what you're doing.