Details
-
Type: Improvement
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 5.3.0-b1
-
Component/s: None
-
Labels:None
Description
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 { // Load traits use Container; /** * @var Monolog\Logger An instance of the logger */ protected $logger; ... public function __construct(Record $local) { ... // Initialize logger $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()); }