Uploaded image for project: 'Blesta Core'
  1. Blesta Core
  2. CORE-4460

Import Manager: Log full stack trace on error

    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());
                  }
      

        Activity

          People

          • Assignee:
            abdy Abdy Franco
            Reporter:
            jonathan Jonathan Reissmueller
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Fix Release Date:
              27/Jan/22

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0 minutes
              0m
              Logged:
              Time Spent - 2 hours, 30 minutes
              2h 30m

                Agile