ioioioioioioi
V2EX  ›  问与答

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

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