Perform a one-off save that will raise an exception on validation error
instead of returning a boolean (which is the default behaviour).

@param  array  $options
@return bool
@throws \Throwable
334830
public function saveOrFail(array $options = [])
    {
        if ($this->isInvalid()) {
            return $this->throwValidationException();
        }

        return $this->getModel()->parentSaveOrFail($options);
    }
70182
public static function fromException($exception, array $options=[]) {
		if ($exception instanceof \Exception === false && $exception instanceof \Throwable === false) {
			throw new InputException('input is not a real exception in php5 or php7');
		}
		
		$options = array_merge(self::$defaults, $options);
		
		$errorsDocument = new self();
		$errorsDocument->addException($exception, $options);
		
		return $errorsDocument;
	}
1372315
public function fromArray($options)
    {
        if (isset($options['Id'])) {
            Validate::isString($options['Id'], 'options[Id]');
            $this->_id = $options['Id'];
        }

        if (isset($options['ErrorCode'])) {
            Validate::isString($options['ErrorCode'], 'options[ErrorCode]');
            $this->_errorCode = $options['ErrorCode'];
        }

        if (isset($options['ErrorMessage'])) {
            Validate::isString($options['ErrorMessage'], 'options[ErrorMessage]');
            $this->_errorMessage = $options['ErrorMessage'];
        }

        if (isset($options['State'])) {
            Validate::isString($options['State'], 'options[State]');
            $this->_state = $options['State'];
        }

        if (isset($options['TargetEntityId'])) {
            Validate::isString($options['TargetEntityId'], 'options[TargetEntityId]');
            $this->_targetEntityId = $options['TargetEntityId'];
        }
    }
74306
protected function convertWriteConcern(array $options)
    {
        if (isset($options['safe']) && ! isset($options['w'])) {
            $options['w'] = is_bool($options['safe']) ? (integer) $options['safe'] : $options['safe'];
            unset($options['safe']);
        }

        return $options;
    }
910053
public function fromArray(array $options)
    {
        if (isset($options['PendingFilesCount'])) {
            Validate::isInteger(
                $options['PendingFilesCount'],
                'options[PendingFilesCount]'
            );
            $this->_pendingFilesCount = $options['PendingFilesCount'];
        }

        if (isset($options['FinishedFilesCount'])) {
            Validate::isInteger(
                $options['FinishedFilesCount'],
                'options[FinishedFilesCount]'
            );
            $this->_finishedFilesCount = $options['FinishedFilesCount'];
        }

        if (isset($options['ErrorFilesCount'])) {
            Validate::isInteger(
                $options['ErrorFilesCount'],
                'options[ErrorFilesCount]'
            );
            $this->_errorFilesCount = $options['ErrorFilesCount'];
        }

        if (isset($options['ErrorFilesDetails'])) {
            Validate::isString(
                $options['ErrorFilesDetails'],
                'options[ErrorFilesDetails]'
            );
            $this->_errorFilesDetails = $options['ErrorFilesDetails'];
        }
    }
337950
public function save( array $options = [] )
    {
        if( $this->exists )
        {
            if( count( $this->getDirty() ) > 0 )
            {
                // If $this->exists and dirty, parent::save() has to return true. If not,
                // an error has occurred. Therefore we shouldn't save the translations.
                if( parent::save( $options ) )
                {
                    return $this->saveTranslations();
                }

                return false;
            }
            else
            {
                // If $this->exists and not dirty, parent::save() skips saving and returns
                // false. So we have to save the translations
                $saved = $this->saveTranslations();

                if( $saved )
                {
                    $this->fireModelEvent( 'saved', false );
                    $this->fireModelEvent( 'updated', false );
                }

                return $saved;
            }
        }
        elseif( parent::save( $options ) )
        {
            // We save the translations only if the instance is saved in the database.
            return $this->saveTranslations();
        }

        return false;
    }
975098
public function fromArray($options)
    {
        if (isset($options['InsertSlateOnAdMarker'])) {
            Validate::isBoolean($options['InsertSlateOnAdMarker'], 'options[InsertSlateOnAdMarker]');
            $this->_insertSlateOnAdMarker = (bool) $options['InsertSlateOnAdMarker'];
        }

        if (isset($options['DefaultSlateAssetId'])) {
            Validate::isString($options['DefaultSlateAssetId'], 'options[DefaultSlateAssetIdUrl]');
            $this->_defaultSlateAssetId = $options['DefaultSlateAssetId'];
        }
    }
1186390
public function save(array $options = null)
    {
        try {
            parent::save($options);
        }
        catch (Exception $ex) {
            $this->throwHalcyonSaveException($ex);
        }
    }
1237789
public function fromArray($options)
    {
        if (isset($options['AccountId'])) {
            Validate::isString($options['AccountId'], 'options[AccountId]');
            $this->_accountId = $options['AccountId'];
        }

        if (isset($options['ReservedUnitType'])) {
            Validate::isInteger($options['ReservedUnitType'], 'options[ReservedUnitType]');
            $this->_reservedUnitType = intval($options['ReservedUnitType']);
        }

        if (isset($options['MaxReservableUnits'])) {
            Validate::isInteger($options['MaxReservableUnits'], 'options[MaxReservableUnits]');
            $this->_maxReservableUnits = intval($options['MaxReservableUnits']);
        }

        if (isset($options['CurrentReservedUnits'])) {
            Validate::isString($options['CurrentReservedUnits'], 'options[CurrentReservedUnits]');
            $this->_currentReservedUnits = intval($options['CurrentReservedUnits']);
        }
    }
577511
protected function validateOptions(int $options)
    {
        // Forbidden combos.
        $combos = [
            self::ABSOLUTE_DISABLED | self::ABSOLUTE_ALLOWED,
            self::ABSOLUTE_DISABLED | self::ABSOLUTE_REQUIRED,
            self::VFS_ALLOWED | self::ABSOLUTE_ALLOWED,
            self::VFS_ALLOWED | self::ABSOLUTE_REQUIRED,
            self::VFS_DISABLED | self::VFS_ALLOWED,
            self::VFS_DISABLED | self::VFS_REQUIRED,
            self::VFS_REQUIRED | self::ABSOLUTE_ALLOWED,
            self::VFS_REQUIRED | self::ABSOLUTE_REQUIRED,
            self::WRAPPER_DISABLED | self::VFS_ALLOWED,
            self::WRAPPER_DISABLED | self::VFS_REQUIRED,
            self::WRAPPER_DISABLED | self::WRAPPER_ALLOWED,
            self::WRAPPER_DISABLED | self::WRAPPER_REQUIRED
        ];
        /** @noinspection ForeachSourceInspection */
        foreach ($combos as $combo) {
            if (($options & $combo) === $combo) {
                $mess = 'Can not use required or allowed options together with corresponding disabled option';
                throw new \DomainException($mess);
            }
        }
    }
488681
protected function addErrorClass(&$options)
    {
        $errors = $this->formHelper->getRequest()->getSession()->get('errors');

        if ($errors && $errors->has($this->getNameKey())) {
            $errorClass = $this->formHelper->getConfig('defaults.wrapper_error_class');

            if ($options['wrapper'] && !str_contains($options['wrapper']['class'], $errorClass)) {
                $options['wrapper']['class'] .= ' '.$errorClass;
            }
        }

        return $options;
    }
104499
public function save($options = [])
    {
        foreach ($this->relations as $related) {
            if (!$related->save()) {
                $this->throwSaveError($related);
            }
        }

        if (!$this->data->save($options)) {
            $this->throwSaveError($this->data);
        }

        $this->data = $this->data->fresh();

        return true;
    }
229277
protected function performCreate(array $options = [])
    {
        if ($this->fireModelEvent('creating') === false) {
            return false;
        }

        $params = $this->setKeysForSave();

        $results = $this->makeRequest($this->getEndpoint(), 'create', [$params]);

        // Creation failed
        if (is_array($results) === false) {
            return false;
        }

        // Fresh start
        $this->attributes = [];

        // Update model with new data
        $this->fill($results);

        // We will go ahead and set the exists property to true, so that it is set when
        // the created event is fired, just in case the developer tries to update it
        // during the event. This will allow them to do so and run an update here.
        $this->exists = true;

        $this->fireModelEvent('created', false);

        return true;
    }
720446
protected function validateFilesystemOptions($options)
	{
		if (preg_match("/:id\b/", $options['url']) !== 1 && preg_match("/:id_partition\b/", $options['url']) !== 1 && preg_match("/:hash\b/", $options['url']) !== 1) {
			throw new Exceptions\InvalidUrlOptionException('Invalid Url: an id, id_partition, or hash interpolation is required.', 1);
		}
	}
813120
public function save(array $options = array())
  {
      // Do some testing before passing onto parent save method
      //if($this->category === null || $this->category->exists === false)
      //{
          //throw new DomainException('Post must be assigned a Category');
      //}

      if(!$this->exists)
      {
        $this->recordEvents(new PostWasCreatedEvent($this));
      }

      $saved = parent::save($options);

      return $saved;
  }
285922
public function save($options = array())
    {

        if ($this->isEmbed()) {
            return false;
        }

        $this->processReferencesChanged();
        $this->processEmbedsChanged();

        /* if no changes then do nothing */

        if ($this->_exist && empty($this->dirtyData) && empty($this->unsetData)) return true;

        $this->__preSave();

        if ($this->_exist) {
            $this->__preUpdate();
            $updateQuery = array();

            if (!empty($this->dirtyData)) {
                $updateQuery['$set'] = self::mapFields($this->dirtyData);
            };

            if (!empty($this->unsetData)) {
                $updateQuery['$unset'] = self::mapFields($this->unsetData);
            }

            $success = $this->_connection->update($this->collectionName(), array('_id' => $this->getId()), $updateQuery, $options);
            $this->__postUpdate();

        } else {
            $this->__preInsert();
            $data = self::mapFields($this->cleanData);
            $insert = $this->_connection->insert($this->collectionName(), $data, $options);
            $success = !is_null($this->cleanData['_id'] = $insert['_id']);
            if ($success) {
                $this->_exist = true ;
                $this->__postInsert();
            }

        }

        $this->dirtyData = array();
        $this->unsetData = array();
        $this->__postSave();

        return $success;

    }
1149195
private function validateOptions(array $options)
    {
        $currentVersion = 6;
        $resolver       = new OptionsResolver();
        $resolver->setDefaults(
            [
                'version'           => $currentVersion,
                'logger'            => new Logger('Logger'),
                'rateLimitProvider' => new MemoryRateLimitProvider(),
                'throwOnRatelimit'  => false,
                'apiUrl'            => "https://discordapp.com/api/v{$currentVersion}/",
                'tokenType'         => 'Bot',
                'cacheDir'          => __DIR__.'/../../../cache/',
                'guzzleOptions'     => [],
            ]
        )
            ->setDefined(['token'])
            ->setAllowedValues('tokenType', ['Bot', 'OAuth'])
            ->setAllowedTypes('token', ['string'])
            ->setAllowedTypes('apiUrl', ['string'])
            ->setAllowedTypes('rateLimitProvider', [AbstractRateLimitProvider::class])
            ->setAllowedTypes('throwOnRatelimit', ['bool'])
            ->setAllowedTypes('logger', ['\Psr\Log\LoggerInterface'])
            ->setAllowedTypes('version', ['string', 'integer'])
            ->setAllowedTypes('guzzleOptions', ['array']);

        return $resolver->resolve($options);
    }