public function toCustomString( int $subExceptionLevel = 0, string $indentSpaces = '   ' ) : string
   {

      // Concatenate the base error message from usable elements
      $msg = \sprintf(
         '%s%s in %s[%d]. %s',
         \str_repeat( $indentSpaces, $subExceptionLevel ),
         \get_class( $this ),
         $this->file,
         $this->line,
         \str_replace( "\n", "\n" . \str_repeat( $indentSpaces, $subExceptionLevel ), $this->message )
      );

      // getting a may defined previous exception
      $previous = $this->getPrevious();

      // if no previous exception is defined return the current generated message
      if ( null === $previous || ! ( $previous instanceof \Throwable ) )
      {
         return $msg;
      }

      // If previous message is a framework internal exception
      if ( $previous instanceof NiirrtyException )
      {
         // Simple cast the exception to a string and append it with rewrite the indention
         $msg .= "\n" . $previous->toCustomString( $subExceptionLevel + 1, $indentSpaces );
         // And return the message
         return $msg;
      }

      // Else its a normal PHP exception
      // Concatenate the previous error message from usable elements
      $msg .= \sprintf(
         "\n%s%s %s in %s[%d]\n    %s",
         \str_repeat( $indentSpaces, $subExceptionLevel + 1 ),
         \get_class( $previous ),
         static::GetCodeName( $previous->getCode() ),
         $previous->file,
         $previous->line,
         \str_replace( "\n", "\n" . \str_repeat( $indentSpaces, $subExceptionLevel + 1 ), $previous->message )
      );

      // And return the message
      return $msg;

   }
public function toCustomString( int $subExceptionLevel = 0, string $indentSpaces = '   ' ) : string
   {

      // Concatenate the base error message from usable elements
      $msg = \sprintf(
         '%s%s in %s[%d]. %s',
         \str_repeat( $indentSpaces, $subExceptionLevel ),
         \get_class( $this ),
         $this->file,
         $this->line,
         \str_replace( "\n", "\n" . \str_repeat( $indentSpaces, $subExceptionLevel ), $this->message )
      );

      // getting a may defined previous exception
      $previous = $this->getPrevious();

      // if no previous exception is defined return the current generated message
      if ( null === $previous || ! ( $previous instanceof \Throwable ) )
      {
         return $msg;
      }

      // If previous message is a framework internal exception
      if ( $previous instanceof NiirrtyException )
      {
         // Simple cast the exception to a string and append it with rewrite the indention
         $msg .= "\n" . $previous->toCustomString( $subExceptionLevel + 1, $indentSpaces );
         // And return the message
         return $msg;
      }

      // Else its a normal PHP exception
      // Concatenate the previous error message from usable elements
      $msg .= \sprintf(
         "\n%s%s %s in %s[%d]\n    %s",
         \str_repeat( $indentSpaces, $subExceptionLevel + 1 ),
         \get_class( $previous ),
         static::GetCodeName( $previous->getCode() ),
         $previous->file,
         $previous->line,
         \str_replace( "\n", "\n" . \str_repeat( $indentSpaces, $subExceptionLevel + 1 ), $previous->message )
      );

      // And return the message
      return $msg;

   }
public function toCustomString ( int $ subExceptionLevel = 0 , string $ indentSpaces = '   ' ) : string { // Concatenate the base error message from usable elements $ msg = \ sprintf ( '%s%s in %s[%d]. %s' , \ str_repeat ( $ indentSpaces , $ subExceptionLevel ) , \ get_class ( $ this ) , $ this -> file , $ this -> line , \ str_replace ( "\n" , "\n" . \ str_repeat ( $ indentSpaces , $ subExceptionLevel ) , $ this -> message ) ) ; // getting a may defined previous exception $ previous = $ this -> getPrevious ( ) ; // if no previous exception is defined return the current generated message if ( null === $ previous || ! ( $ previous instanceof \ Throwable ) ) { return $ msg ; } // If previous message is a framework internal exception if ( $ previous instanceof NiirrtyException ) { // Simple cast the exception to a string and append it with rewrite the indention $ msg .= "\n" . $ previous -> toCustomString ( $ subExceptionLevel + 1 , $ indentSpaces ) ; // And return the message return $ msg ; } // Else its a normal PHP exception // Concatenate the previous error message from usable elements $ msg .= \ sprintf ( "\n%s%s %s in %s[%d]\n    %s" , \ str_repeat ( $ indentSpaces , $ subExceptionLevel + 1 ) , \ get_class ( $ previous ) , static :: GetCodeName ( $ previous -> getCode ( ) ) , $ previous -> file , $ previous -> line , \ str_replace ( "\n" , "\n" . \ str_repeat ( $ indentSpaces , $ subExceptionLevel + 1 ) , $ previous -> message ) ) ; // And return the message return $ msg ; }
Allows the definition of the sub exception level if there is a parent exception that contains this exception.

@param  int     $subExceptionLevel
@param  string  $indentSpaces      Spaces to use for a single indention level.
@return string
Allows the definition of the sub exception level if there is a parent exception that contains this exception .