Kraken\Throwable\Exception::toThrowableTrace PHP Method

toThrowableTrace() public static method

Return Exception throwable trace in array format.
public static toThrowableTrace ( Error | Exception $ex ) : string[]
$ex Error | Exception
return string[]
    public static function toThrowableTrace($ex)
    {
        $list = [];
        for ($stack = Throwable::getThrowableStack($ex); $stack !== null; $stack = $stack['prev']) {
            $list[] = Throwable::parseThrowableMessage($stack);
        }
        return array_reverse($list);
    }

Usage Example

Example #1
0
 /**
  *
  */
 public function testStaticApiToThrowableTrace_ReturnsStackThrowable()
 {
     $prev = $this->createException('Previous');
     $ex = $this->createException('Exception', $prev);
     $this->assertThrowableTrace(Exception::toThrowableTrace($ex));
 }