Kraken\Throwable\Throwable::getThrowableData PHP Method

getThrowableData() public static method

Return throwable data in array format.
public static getThrowableData ( Error | Exception $ex, integer $offset ) : string[]
$ex Error | Exception
$offset integer
return string[]
    public static function getThrowableData($ex, $offset = 0)
    {
        return ['message' => $ex->getMessage(), 'class' => get_class($ex), 'file' => $ex->getFile(), 'line' => $ex->getLine(), 'code' => $ex->getCode(), 'trace' => static::getTraceElements($ex, $offset), 'isError' => $ex instanceof \Error, 'prev' => null];
    }

Usage Example

Example #1
0
 /**
  *
  */
 public function testStaticApiGetThrowableData_ReturnsData_ForException()
 {
     $prev = $this->createException('Previous');
     $ex = $this->createException($message = 'Exception', $prev);
     $data = Throwable::getThrowableData($ex);
     $this->assertData($data);
 }