Currently, whenever an exception is encountered by the import manager, we output only the exception message. So we end up with unhelpful sql exception like
importContacts: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'client_id' cannot be null on line 196
Line 196 tells us nothing of where in the importer code the error was encountered. Lets update the Import Manager to use monolog to record the full stack trace so we get some more useful debugging info.
<?php
use Blesta\Core\Util\Common\Traits\Container;
...
abstract class Migrator
{
use Container;
/**
* @var Monolog\Logger An instance of the logger
*/
protected $logger;
...
public function __construct(Record $local)
{
...
$logger = $this->getFromContainer('logger');
$this->logger = $logger;
}
And in the importers change from something like this
} catch (Exception $e) {
$errors[] = $action . ': ' . $e->getMessage() . ' on line ' . $e->getLine();
}
To something like this
} catch (Exception $e) {
$errors[] = $action . ': ' . $e->getMessage() . ' on line ' . $e->getLine();
$this->logger->error($e->getTraceAsString());
}