Throwing exception within exception handler

后端 未结 5 1156
温柔的废话
温柔的废话 2021-02-19 18:44

I have a script with an exception handler. This exception handler cleans up a couple connections, prior to the script exiting after an exception.

I would like to re-thr

5条回答
  •  Happy的楠姐
    2021-02-19 19:25

    Just rethrow the exception as a RunTimeException and it will keep the stacktrace :)

    try {
        // bad exception throwing code
    } catch (Exception $e) {
        throw new RuntimeException($e->getMessage(), $e->getCode(), $e);
    }
    

提交回复
热议问题