You are here

class SyncException in CMS Content Sync 2.0.x

Same name and namespace in other branches
  1. 8 src/Exception/SyncException.php \Drupal\cms_content_sync\Exception\SyncException
  2. 2.1.x src/Exception/SyncException.php \Drupal\cms_content_sync\Exception\SyncException

Class SyncException, thrown if anything goes wrong during pull / push of entities for Content Sync. Will be caught by the Flow synchronization class, saved to the logs, presented to the user and returned to Sync Core.

Hierarchy

  • class \Drupal\cms_content_sync\Exception\SyncException extends \Drupal\cms_content_sync\Exception\Exception

Expanded class hierarchy of SyncException

7 files declare their use of SyncException
cms_content_sync.module in ./cms_content_sync.module
Module file for cms_content_sync.
DefaultTaxonomyHandler.php in src/Plugin/cms_content_sync/entity_handler/DefaultTaxonomyHandler.php
EntityHandlerBase.php in src/Plugin/EntityHandlerBase.php
EntityResource.php in src/Plugin/rest/resource/EntityResource.php
PushIntent.php in src/PushIntent.php

... See full list

File

src/Exception/SyncException.php, line 11

Namespace

Drupal\cms_content_sync\Exception
View source
class SyncException extends \Exception {

  /**
   * @var string CODE_ENTITY_API_FAILURE
   *             The entity API returned an unexpected error at some point, e.g. when
   *             saving an entity. More information is available at
   *             {@see SyncException::$parentException}.
   */
  public const CODE_ENTITY_API_FAILURE = 'ENTITY_API_FAILURE';

  /**
   * @var string CODE_UNEXPECTED_EXCEPTION
   *             Any unexpected exception was thrown during synchronization. The exception
   *             is available via {@see SyncException::$parentException}.
   */
  public const CODE_UNEXPECTED_EXCEPTION = 'UNEXPECTED_EXCEPTION';

  /**
   * @var string CODE_PUSH_REQUEST_FAILED
   *             The push request to the Sync Core backend failed. The request failure
   *             exception is available via {@see SyncException::$parentException}.
   */
  public const CODE_PUSH_REQUEST_FAILED = 'EXPORT_REQUEST_FAILED';

  /**
   * @var string CODE_INVALID_PULL_REQUEST
   *             The pull request from Sync Core was invalid
   */
  public const CODE_INVALID_PULL_REQUEST = 'INVALID_REQUEST';

  /**
   * @var string CODE_INTERNAL_ERROR
   *             An internal error occurred while processing the request
   */
  public const CODE_INTERNAL_ERROR = 'INTERNAL_ERROR';

  /**
   * @var string
   *             The error code constant (see below)
   */
  public $errorCode;

  /**
   * @var \Exception
   *                 The parent exception that caused this exception, if any
   */
  public $parentException;

  /**
   * SyncException constructor.
   *
   * @param string     $errorCode
   *                                    See SyncException::CODE_*
   * @param \Exception $parentException
   *                                    {@see SyncException::$parentException}
   * @param string     $message
   *                                    Optional message to describe the error in more detail
   */
  public function __construct($errorCode, \Exception $parentException = null, $message = null) {
    parent::__construct($message ? $message : $errorCode);
    $this->errorCode = $errorCode;
    $this->parentException = $parentException;
  }

  /**
   * @param bool $nested
   *
   * @return null|\Exception
   */
  public function getRootException($nested = false) {
    if ($this->parentException) {
      if ($this->parentException instanceof SyncException) {
        return $this->parentException
          ->getRootException(true);
      }
      return $this->parentException;
    }
    if ($nested) {
      return $this;
    }
    return null;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SyncException::$errorCode public property The error code constant (see below)
SyncException::$parentException public property The parent exception that caused this exception, if any
SyncException::CODE_ENTITY_API_FAILURE public constant The entity API returned an unexpected error at some point, e.g. when saving an entity. More information is available at {
SyncException::CODE_INTERNAL_ERROR public constant An internal error occurred while processing the request
SyncException::CODE_INVALID_PULL_REQUEST public constant The pull request from Sync Core was invalid
SyncException::CODE_PUSH_REQUEST_FAILED public constant The push request to the Sync Core backend failed. The request failure exception is available via {
SyncException::CODE_UNEXPECTED_EXCEPTION public constant Any unexpected exception was thrown during synchronization. The exception is available via {
SyncException::getRootException public function
SyncException::__construct public function SyncException constructor.