Doctrine 1
  1. Doctrine 1
  2. DC-148

When running cli tasks and there's an exception/error - it's helpful to have detailed information displayed

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2.0-ALPHA3
    • Fix Version/s: 1.2.0-BETA1
    • Component/s: Cli
    • Labels:
      None
    • Environment:
      Cli Tasks

      Description

      We don't always get enough information when an exception happens to track down where the issue is.
      It would be helpful if the tablename and/or the SQL statement was also displayed to help track down problems.

      When trying to load a fixture file I was receiving the following:
      [Doctrine_Connection_Mysql_Exception]
      SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'created_at' cannot be null

      As you can see - it doesn't help much as it doesn't display the table/class that's the created_at column is on.

      As quick fix - I modified the rethrowException method in Doctrine_Connection to include some information from the invoker (not a great fix - I should really dig deeper and see if there's a __toString() method on classes that can be passed as the invoker):

      Unable to find source-code formatter for language: php. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml
          /**
           * rethrowException
           *
           * @throws Doctrine_Connection_Exception
           */
          public function rethrowException(Exception $e, $invoker)
          {
              $event = new Doctrine_Event($this, Doctrine_Event::CONN_ERROR);
      
              $this->getListener()->preError($event);
              
              $name = 'Doctrine_Connection_' . $this->driverName . '_Exception';
              
              $exc  = new $name($e->getMessage() . "\n" . $invoker->getQuery(), (int) $e->getCode());
              if ( ! isset($e->errorInfo) || ! is_array($e->errorInfo)) {
                  $e->errorInfo = array(null, null, null, null);
              }
              $exc->processErrorInfo($e->errorInfo);
      
               if ($this->getAttribute(Doctrine_Core::ATTR_THROW_EXCEPTIONS)) {
                  throw $exc;
              }
              
              $this->getListener()->postError($event);
          }
      

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            D Ashwood
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: