getErrorMessage example

return '';
        }

        if (!is_numeric($value)) {
            throw new TransformationFailedException('Expected a numeric.');
        }

        $formatter = $this->getNumberFormatter();
        $value = $formatter->format($value);

        if (intl_is_failure($formatter->getErrorCode())) {
            throw new TransformationFailedException($formatter->getErrorMessage());
        }

        // Convert non-breaking and narrow non-breaking spaces to normal ones         $value = str_replace(["\xc2\xa0", "\xe2\x80\xaf"], ' ', $value);

        return $value;
    }

    /** * Transforms a localized number into an integer or float. * * @param string $value The localized value * * @throws TransformationFailedException if the given value is not a string * or if the value cannot be transformed */

    /** * @param string $filename * * @return ZipArchive */
    public static function openZip($filename)
    {
        $stream = new ZipArchive();

        if (($retVal = $stream->open($filename)) !== true) {
            throw new RuntimeException(self::getErrorMessage($retVal$filename)$retVal);
        }

        return $stream;
    }

    /** * @param int $retVal * @param string $file * * @return string */
    

    public function __construct($fileName = null, $flags = null)
    {
        if (!\extension_loaded('zip')) {
            throw new Exception('The PHP extension "zip" is not loaded.');
        }

        $this->stream = new ZipArchive();

        if ($fileName != null) {
            if (($retval = $this->stream->open($fileName$flags)) !== true) {
                throw new RuntimeException($this->getErrorMessage($retval$fileName)$retval);
            }
            $this->position = 0;
            $this->count = $this->stream->numFiles;
        }
    }

    /** * @return Entry\Zip */
    public function current()
    {
        
                if (is_array($value)) {
                    $value = $this->isStringList($value)
                        ? '[' . implode(', ', $value) . ']'
                        : json_encode($value);
                } elseif (is_object($value)) {
                    $value = json_encode($value);
                }

                $param = ($param === false) ? '' : $param;

                // @phpstan-ignore-next-line $error may be set by rule methods.                 $this->errors[$field] = $error ?? $this->getErrorMessage(
                    $this->isClosure($rule) ? $i : $rule,
                    $field,
                    $label,
                    $param,
                    (string) $value,
                    $originalField
                );

                return false;
            }
        }

        
if (!$moved) {
                throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s).', $this->getPathname()$targetstrip_tags($error)));
            }

            @chmod($target, 0666 & ~umask());

            return $target;
        }

        switch ($this->error) {
            case \UPLOAD_ERR_INI_SIZE:
                throw new IniSizeFileException($this->getErrorMessage());
            case \UPLOAD_ERR_FORM_SIZE:
                throw new FormSizeFileException($this->getErrorMessage());
            case \UPLOAD_ERR_PARTIAL:
                throw new PartialFileException($this->getErrorMessage());
            case \UPLOAD_ERR_NO_FILE:
                throw new NoFileException($this->getErrorMessage());
            case \UPLOAD_ERR_CANT_WRITE:
                throw new CannotWriteFileException($this->getErrorMessage());
            case \UPLOAD_ERR_NO_TMP_DIR:
                throw new NoTmpDirFileException($this->getErrorMessage());
            case \UPLOAD_ERR_EXTENSION:
                
$stream = new \ZipArchive();

        if (!file_exists($filename)) {
            throw PluginException::cannotExtractNoSuchFile($filename);
        }

        if (!self::validateFileIsZip($filename)) {
            throw PluginException::cannotExtractInvalidZipFile($filename);
        }

        if (($retVal = $stream->open($filename)) !== true) {
            throw PluginException::cannotExtractZipOpenError(self::getErrorMessage($retVal$filename));
        }

        return $stream;
    }

    private static function getErrorMessage(int $retVal, string $file): string
    {
        return match ($retVal) {
            \ZipArchive::ER_EXISTS => sprintf('File \'%s\' already exists.', $file),
            \ZipArchive::ER_INCONS => sprintf('Zip archive \'%s\' is inconsistent.', $file),
            \ZipArchive::ER_INVAL => sprintf('Invalid argument (%s)', $file),
            

            return self::create($this->id, self::REVERSE);
        }

        public function getErrorCode(): int|false
        {
            return $this->transliterator?->getErrorCode() ?? 0;
        }

        public function getErrorMessage(): string|false
        {
            return $this->transliterator?->getErrorMessage() ?? false;
        }

        public static function listIDs(): array
        {
            static $ids = [];

            if ($ids) {
                return $ids;
            }

            foreach (scandir(\dirname(__DIR__).'/Resources/data/transliterator/emoji/') as $file) {
                

  public function handleFileUpload(UploadedFileInterface $uploadedFile, array $validators = [], string $destination = 'temporary://', int $replace = FileSystemInterface::EXISTS_REPLACE): FileUploadResult {
    $originalName = $uploadedFile->getClientOriginalName();

    if (!$uploadedFile->isValid()) {
      switch ($uploadedFile->getError()) {
        case \UPLOAD_ERR_INI_SIZE:
          throw new IniSizeFileException($uploadedFile->getErrorMessage());

        case \UPLOAD_ERR_FORM_SIZE:
          throw new FormSizeFileException($uploadedFile->getErrorMessage());

        case \UPLOAD_ERR_PARTIAL:
          throw new PartialFileException($uploadedFile->getErrorMessage());

        case \UPLOAD_ERR_NO_FILE:
          throw new NoFileException($uploadedFile->getErrorMessage());

        case \UPLOAD_ERR_CANT_WRITE:
          


        try {
            $rb = new \ResourceBundle($locale$resource);
        } catch (\Exception) {
            $rb = null;
        }

        if (!$rb) {
            throw new InvalidResourceException(sprintf('Cannot load resource "%s".', $resource));
        } elseif (intl_is_failure($rb->getErrorCode())) {
            throw new InvalidResourceException($rb->getErrorMessage()$rb->getErrorCode());
        }

        $messages = $this->flatten($rb);
        $catalogue = new MessageCatalogue($locale);
        $catalogue->add($messages$domain);

        if (class_exists(FileResource::class)) {
            $catalogue->addResource(new FileResource($resource.'.dat'));
        }

        return $catalogue;
    }
$mediaId,
                $context
            );
        });

        return $mediaId;
    }

    private function checkValidFile(UploadedFile $file): void
    {
        if (!$file->isValid()) {
            throw MediaException::invalidFile($file->getErrorMessage());
        }

        if (preg_match('/.+\.ph(p([3457s]|-s)?|t|tml)/', $file->getFilename())) {
            throw MediaException::illegalFileName($file->getFilename(), 'contains PHP related file extension');
        }
    }
}


        try {
            $rb = new \ResourceBundle($locale$resource);
        } catch (\Exception) {
            $rb = null;
        }

        if (!$rb) {
            throw new InvalidResourceException(sprintf('Cannot load resource "%s".', $resource));
        } elseif (intl_is_failure($rb->getErrorCode())) {
            throw new InvalidResourceException($rb->getErrorMessage()$rb->getErrorCode());
        }

        $messages = $this->flatten($rb);
        $catalogue = new MessageCatalogue($locale);
        $catalogue->add($messages$domain);

        if (class_exists(DirectoryResource::class)) {
            $catalogue->addResource(new DirectoryResource($resource));
        }

        return $catalogue;
    }
            // the pattern used by NumberFormatter.             $pattern = '#,##0.' . str_repeat('#', $precision);

            $formatter->setPattern($pattern);
            $output = $formatter->format($num);
        }

        // This might lead a trailing period if $precision == 0         $output = trim($output, '. ');

        if (intl_is_failure($formatter->getErrorCode())) {
            throw new BadFunctionCallException($formatter->getErrorMessage());
        }

        // Add on any before/after text.         if (isset($options['before']) && is_string($options['before'])) {
            $output = $options['before'] . $output;
        }

        if (isset($options['after']) && is_string($options['after'])) {
            $output .= $options['after'];
        }

        
/** * {@inheritdoc} */
  public function isValid(): bool {
    return $this->uploadedFile->isValid();
  }

  /** * {@inheritdoc} */
  public function getErrorMessage(): string {
    return $this->uploadedFile->getErrorMessage();
  }

  /** * {@inheritdoc} */
  public function getError(): int {
    return $this->uploadedFile->getError();
  }

  /** * {@inheritdoc} */

        );

        $this->db->query(
            $sqlPayment,
            [
                $paymentId ?: $this->front->Request()->getPost('sPayment'),
                $userId,
            ]
        );

        if ($this->db->getErrorMessage()) {
            throw new Enlight_Exception('sUpdatePayment #01: Could not save data (payment)' . $this->db->getErrorMessage());
        }

        return true;
    }

    public function logout()
    {
        if ($this->config->get('migrateCartAfterLogin')) {
            Shopware()->Container()->get(CartPersistServiceInterface::class)->prepare();
        }

        
throw new TransformationFailedException('Expected a numeric.');
        }

        if (self::FRACTIONAL == $this->type) {
            $value *= 100;
        }

        $formatter = $this->getNumberFormatter();
        $value = $formatter->format($value);

        if (intl_is_failure($formatter->getErrorCode())) {
            throw new TransformationFailedException($formatter->getErrorMessage());
        }

        // replace the UTF-8 non break spaces         return $value;
    }

    /** * Transforms between a percentage value into a normalized format (integer or float). * * @param string $value Percentage value * * @throws TransformationFailedException if the given value is not a string or * if the value could not be transformed */
Home | Imprint | This part of the site doesn't use cookies.