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

        jonathan Jonathan Reissmueller created issue -
        jonathan Jonathan Reissmueller made changes -
        Field Original Value New Value
        Story Points 3
        jonathan Jonathan Reissmueller made changes -
        Summary Import Manage: Log full stack trace on error Import Manager: Log full stack trace on error
        jonathan Jonathan Reissmueller made changes -
        Fix Version/s 5.3.0-b1 [ 11711 ]
        Fix Version/s 5.2.0 [ 11718 ]
        jonathan Jonathan Reissmueller made changes -
        Sprint 5.3.0 Sprint 1 [ 138 ]
        jonathan Jonathan Reissmueller made changes -
        Rank Ranked higher
        abdy Abdy Franco made changes -
        Assignee Abdy Franco [ abdy ]
        abdy Abdy Franco made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        abdy Abdy Franco made changes -
        Remaining Estimate 0 minutes [ 0 ]
        Time Spent 2 hours, 30 minutes [ 9000 ]
        Worklog Id 15286 [ 15286 ]
        abdy Abdy Franco made changes -
        Status In Progress [ 3 ] In Review [ 5 ]
        Resolution Fixed [ 1 ]
        jonathan Jonathan Reissmueller made changes -
        Status In Review [ 5 ] Closed [ 6 ]

          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