Kraken\Throwable\Exception::toThrowableString PHP 메소드

toThrowableString() 공개 정적인 메소드

Return Exception throwable trace in string format.
public static toThrowableString ( Error | Exception $ex ) : string
$ex Error | Exception
리턴 string
    public static function toThrowableString($ex)
    {
        $stack = [];
        $i = 0;
        $trace = static::toThrowableTrace($ex);
        $pad = strlen(count($trace)) > 2 ?: 2;
        foreach ($trace as $element) {
            $stack[] = "\t" . str_pad('' . $i, $pad, ' ', STR_PAD_LEFT) . '. ' . $element;
            ++$i;
        }
        return implode("\n", $stack);
    }

Usage Example

예제 #1
0
 /**
  *
  */
 public function testStaticApiToThrowableString_ReturnsThrowableTraceAsString()
 {
     $prev = $this->createException('Previous');
     $ex = $this->createException('Exception', $prev);
     $this->assertThrowableString(Exception::toThrowableString($ex));
 }