parent
							
								
									593d2c27a3
								
							
						
					
					
						commit
						9509c69c66
					
				@ -1,23 +0,0 @@ | 
				
			||||
<?php | 
				
			||||
/* For licensing terms, see /license.txt */ | 
				
			||||
 | 
				
			||||
namespace Chamilo\PluginBundle\MigrationMoodle\Exceptions; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * Class Exception. | 
				
			||||
 * | 
				
			||||
 * @package Chamilo\PluginBundle\MigrationMoodle\Exceptions | 
				
			||||
 */ | 
				
			||||
abstract class Exception extends \Exception | 
				
			||||
{ | 
				
			||||
    public function displayAsString() | 
				
			||||
    { | 
				
			||||
        $pieces = [$this->getMessage()]; | 
				
			||||
 | 
				
			||||
        if ($this->getPrevious()) { | 
				
			||||
            $pieces[] = "\t".$this->getPrevious()->getMessage(); | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        echo implode(PHP_EOL, $pieces); | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
@ -1,28 +1,34 @@ | 
				
			||||
<?php | 
				
			||||
/* For licensing terms, see /license.txt */ | 
				
			||||
 | 
				
			||||
namespace Chamilo\PluginBundle\MigrationMoodle\Exceptions; | 
				
			||||
namespace Chamilo\PluginBundle\MigrationMoodle\Messages; | 
				
			||||
 | 
				
			||||
use Throwable; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * Class LoadException. | 
				
			||||
 * Class LoadMessage. | 
				
			||||
 * | 
				
			||||
 * @package Chamilo\PluginBundle\MigrationMoodle\Exceptions | 
				
			||||
 * @package Chamilo\PluginBundle\MigrationMoodle\Messages | 
				
			||||
 */ | 
				
			||||
class LoadException extends Exception | 
				
			||||
class LoadMessage extends Message | 
				
			||||
{ | 
				
			||||
    /** | 
				
			||||
     * @var array | 
				
			||||
     */ | 
				
			||||
    private $incomingData; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * LoadMessage constructor. | 
				
			||||
     * | 
				
			||||
     * @param                $incomingData | 
				
			||||
     * @param Throwable|null $previous | 
				
			||||
     */ | 
				
			||||
    public function __construct($incomingData, Throwable $previous = null) | 
				
			||||
    { | 
				
			||||
        $message = 'Error while loading transformed data.'; | 
				
			||||
        $this->incomingData = $incomingData; | 
				
			||||
 | 
				
			||||
        parent::__construct($message, 0, $previous); | 
				
			||||
        parent::__construct($message, $previous); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public function displayAsString() | 
				
			||||
@ -0,0 +1,64 @@ | 
				
			||||
<?php | 
				
			||||
/* For licensing terms, see /license.txt */ | 
				
			||||
 | 
				
			||||
namespace Chamilo\PluginBundle\MigrationMoodle\Messages; | 
				
			||||
 | 
				
			||||
use Throwable; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * Class Message. | 
				
			||||
 * | 
				
			||||
 * @package Chamilo\PluginBundle\MigrationMoodle\Messages | 
				
			||||
 */ | 
				
			||||
abstract class Message | 
				
			||||
{ | 
				
			||||
    /** | 
				
			||||
     * @var string | 
				
			||||
     */ | 
				
			||||
    protected $message; | 
				
			||||
    /** | 
				
			||||
     * @var Throwable | 
				
			||||
     */ | 
				
			||||
    protected $previous; | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * Message constructor. | 
				
			||||
     * | 
				
			||||
     * @param string         $message | 
				
			||||
     * @param Throwable|null $previous | 
				
			||||
     */ | 
				
			||||
    public function __construct($message = "", Throwable $previous = null) | 
				
			||||
    { | 
				
			||||
        $this->message = $message; | 
				
			||||
        $this->previous = $previous; | 
				
			||||
 | 
				
			||||
        $this->displayAsString(); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @return string | 
				
			||||
     */ | 
				
			||||
    public function getMessage() | 
				
			||||
    { | 
				
			||||
        return $this->message; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    /** | 
				
			||||
     * @return Throwable | 
				
			||||
     */ | 
				
			||||
    public function getPrevious() | 
				
			||||
    { | 
				
			||||
        return $this->previous; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    public function displayAsString() | 
				
			||||
    { | 
				
			||||
        $pieces = [$this->message]; | 
				
			||||
 | 
				
			||||
        if ($this->previous) { | 
				
			||||
            $pieces[] = "\t".$this->previous->getMessage(); | 
				
			||||
        } | 
				
			||||
 | 
				
			||||
        echo implode(PHP_EOL, $pieces); | 
				
			||||
    } | 
				
			||||
} | 
				
			||||
					Loading…
					
					
				
		Reference in new issue