国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

Gateworker要如何正確使用異常捕捉?

scan_z

本地win10系統(tǒng)測試:
在異步進程處理curl訪問的時候捕捉異常必須用 catch (\Error $e)才能捕捉到,
在外面代碼捕捉mysql異常必須 catch (\Exception $e) 才能捕捉到,

請問要如何正確使用這種catch捕捉異常?我線上環(huán)境PHP版本和本地都一樣,就是系統(tǒng)不一樣會影響使用方式不?

3380 2 0
2個回答

抽不完的寂寞

我覺得和系統(tǒng)沒關(guān)系,和GatewayWorker也沒關(guān)系。這個是php的語法,主要看php版本,php版本一樣,使用方式就一樣

  • scan_z 2020-05-27

    我是同PHP版本同代碼測試的,使用方式不一樣。

抽不完的寂寞

Error是 PHP 7 的新特性

即,PHP 7 開始,Error 與 Exception 都是繼承自 Throwable。

從 Throwable 的繼承關(guān)系,可以看到 Error 與 Exception 是平級的關(guān)系。

interface Throwable
  |- Error implements Throwable
      |- ArithmeticError extends Error
          |- DivisionByZeroError extends ArithmeticError
      |- AssertionError extends Error
      |- ParseError extends Error
      |- TypeError extends Error
          |- ArgumentCountError extends TypeError
  |- Exception implements Throwable
      |- ClosedGeneratorException extends Exception
      |- DOMException extends Exception
      |- ErrorException extends Exception
      |- IntlException extends Exception
      |- LogicException extends Exception
          |- BadFunctionCallException extends LogicException
              |- BadMethodCallException extends BadFunctionCallException
          |- DomainException extends LogicException
          |- InvalidArgumentException extends LogicException
          |- LengthException extends LogicException
          |- OutOfRangeException extends LogicException
      |- PharException extends Exception
      |- ReflectionException extends Exception
      |- RuntimeException extends Exception
          |- OutOfBoundsException extends RuntimeException
          |- OverflowException extends RuntimeException
          |- PDOException extends RuntimeException
          |- RangeException extends RuntimeException
          |- UnderflowException extends RuntimeException
          |- UnexpectedValueException extends RuntimeException

如果你用的是php7,直接 catch (\Throwable $e) 就行。否則Error 和 Exception 你就要2個都要catch

年代過于久遠,無法發(fā)表回答
??