phar-io/manifest · error · ManifestLoaderException

Processing string failed

Error message

Processing string failed

What it means

ManifestLoader::fromString() maps a manifest supplied as an XML string and wraps any Exception (XML parse failure or mapping failure) into ManifestLoaderException with the fixed message 'Processing string failed'. The original exception is chained as previous, so details are only visible there.

Solutions

  1. Inspect $e->getPrevious()->getMessage() for the actual XML or mapping error
  2. Validate the XML string with a parser or schema check before handing it to fromString()
  3. Log the input string (or write it to a temp file) when the failure occurs to spot corruption

Example fix

// before
catch (ManifestLoaderException $e) { echo $e->getMessage(); } // 'Processing string failed'
// after
catch (ManifestLoaderException $e) {
    echo $e->getMessage();
    if ($e->getPrevious()) echo ": " . $e->getPrevious()->getMessage();
}
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure the string is well-formed XML first
$dom = new DOMDocument();
if (!$dom->loadXML($manifestString)) {
    throw new InvalidArgumentException('Manifest string is not valid XML');
}

Try / catch

try {
    $manifest = ManifestLoader::fromString($xml);
} catch (ManifestLoaderException $e) {
    $cause = $e->getPrevious(); // holds XML or mapping error details
}

Prevention

When it happens

Trigger: fromString() with malformed XML, an empty string, valid XML that fails schema expectations, or content that fails mapping (unsupported type, bad version constraints).

Common situations: Manifests fetched from an API or embedded in another file; unit tests feeding invalid XML to verify error behavior; truncated strings.

Related errors


AI-assisted analysis of phar-io/manifest@c581d4941e (2026-09-14). Data as JSON: /api/errors/b74d15f771391534. Report an issue: GitHub.

Appendix: source

Thrown at src/ManifestLoader.php:40

            throw new ManifestLoaderException(
                sprintf('Loading %s failed.', $filename),
                (int)$e->getCode(),
                $e
            );
        }
    }

    public static function fromPhar(string $filename): Manifest {
        return self::fromFile('phar://' . $filename . '/manifest.xml');
    }

    public static function fromString(string $manifest): Manifest {
        try {
            return (new ManifestDocumentMapper())->map(
                ManifestDocument::fromString($manifest)
            );
        } catch (Exception $e) {
            throw new ManifestLoaderException(
                'Processing string failed',
                (int)$e->getCode(),
                $e
            );
        }
    }
}

View on GitHub (pinned to c581d4941e)