{"record":{"id":"b74d15f771391534","repo":"phar-io/manifest","slug":"processing-string-failed","errorCode":null,"errorMessage":"Processing string failed","messagePattern":"Processing string failed","errorType":"exception","errorClass":"ManifestLoaderException","httpStatus":null,"severity":"error","filePath":"src/ManifestLoader.php","lineNumber":40,"sourceCode":"            throw new ManifestLoaderException(\n                sprintf('Loading %s failed.', $filename),\n                (int)$e->getCode(),\n                $e\n            );\n        }\n    }\n\n    public static function fromPhar(string $filename): Manifest {\n        return self::fromFile('phar://' . $filename . '/manifest.xml');\n    }\n\n    public static function fromString(string $manifest): Manifest {\n        try {\n            return (new ManifestDocumentMapper())->map(\n                ManifestDocument::fromString($manifest)\n            );\n        } catch (Exception $e) {\n            throw new ManifestLoaderException(\n                'Processing string failed',\n                (int)$e->getCode(),\n                $e\n            );\n        }\n    }\n}\n","sourceCodeStart":22,"sourceCodeEnd":48,"githubUrl":"https://github.com/phar-io/manifest/blob/c581d4941e196459bf76c945a8ca922963a66708/src/ManifestLoader.php#L22-L48","documentation":"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.","triggerScenarios":"fromString() with malformed XML, an empty string, valid XML that fails schema expectations, or content that fails mapping (unsupported type, bad version constraints).","commonSituations":"Manifests fetched from an API or embedded in another file; unit tests feeding invalid XML to verify error behavior; truncated strings.","solutions":["Inspect $e->getPrevious()->getMessage() for the actual XML or mapping error","Validate the XML string with a parser or schema check before handing it to fromString()","Log the input string (or write it to a temp file) when the failure occurs to spot corruption"],"exampleFix":"// before\ncatch (ManifestLoaderException $e) { echo $e->getMessage(); } // 'Processing string failed'\n// after\ncatch (ManifestLoaderException $e) {\n    echo $e->getMessage();\n    if ($e->getPrevious()) echo \": \" . $e->getPrevious()->getMessage();\n}","handlingStrategy":"try-catch","validationCode":"// ensure the string is well-formed XML first\n$dom = new DOMDocument();\nif (!$dom->loadXML($manifestString)) {\n    throw new InvalidArgumentException('Manifest string is not valid XML');\n}","typeGuard":null,"tryCatchPattern":"try {\n    $manifest = ManifestLoader::fromString($xml);\n} catch (ManifestLoaderException $e) {\n    $cause = $e->getPrevious(); // holds XML or mapping error details\n}","preventionTips":["Validate XML well-formedness before passing to fromString()","Never rely on 'Processing string failed' alone — read the chained exception","Trim BOM/whitespace from strings sourced from files or APIs"],"tags":["php","xml","manifest","exception-wrapping"],"backgroundTag":"xml-parse-error","analyzedSha":"c581d4941e196459bf76c945a8ca922963a66708","analyzedAt":"2026-09-14T11:08:47.165Z","contentChangedAt":"2026-09-14T11:08:47.165Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}