{"record":{"id":"8b85137981b59375","repo":"symfony/translation","slug":"rb-geterrormessage","errorCode":null,"errorMessage":"$rb->getErrorMessage()","messagePattern":"\\$rb->getErrorMessage\\(\\)","errorType":"exception","errorClass":"InvalidResourceException","httpStatus":null,"severity":"error","filePath":"Loader/IcuDatFileLoader.php","lineNumber":45,"sourceCode":"    {\n        if (!stream_is_local($resource.'.dat')) {\n            throw new InvalidResourceException(\\sprintf('This is not a local file \"%s\".', $resource));\n        }\n\n        if (!file_exists($resource.'.dat')) {\n            throw new NotFoundResourceException(\\sprintf('File \"%s\" not found.', $resource));\n        }\n\n        try {\n            $rb = new \\ResourceBundle($locale, $resource);\n        } catch (\\Exception) {\n            $rb = null;\n        }\n\n        if (!$rb) {\n            throw new InvalidResourceException(\\sprintf('Cannot load resource \"%s\".', $resource));\n        } elseif (intl_is_failure($rb->getErrorCode())) {\n            throw new InvalidResourceException($rb->getErrorMessage(), $rb->getErrorCode());\n        }\n\n        $messages = $this->flatten($rb);\n        $catalogue = new MessageCatalogue($locale);\n        $catalogue->add($messages, $domain);\n\n        if (class_exists(FileResource::class)) {\n            $catalogue->addResource(new FileResource($resource.'.dat'));\n        }\n\n        return $catalogue;\n    }\n}\n","sourceCodeStart":27,"sourceCodeEnd":59,"githubUrl":"https://github.com/symfony/translation/blob/ae9e8a51bc29780d63c7f9efd6005d7c875e100b/Loader/IcuDatFileLoader.php#L27-L59","documentation":"IcuDatFileLoader::load() throws InvalidResourceException($rb->getErrorMessage(), $rb->getErrorCode()) when intl_is_failure() reports the ResourceBundle's error code is a failure. The message is the ICU/intl error text itself, so the thrown message equals whatever ICU reported (e.g. 'U_MISSING_RESOURCE_ERROR').","triggerScenarios":"ResourceBundle was created successfully but its internal error code is an ICU failure (e.g. U_MISSING_RESOURCE_ERROR, U_FILE_ACCESS_ERROR), detected via intl_is_failure($rb->getErrorCode()).","commonSituations":"Bundle file exists but the requested locale table is missing inside it, ICU data file access issues (permissions, open_basedir), or an ICU version mismatch producing warnings escalated to failures.","solutions":["Log/inspect the ICU error code (the exception code) and map it: U_MISSING_RESOURCE_ERROR means the locale is absent from the bundle.","Rebuild the bundle to include the requested locales.","Fix filesystem access (permissions/open_basedir) if the code is U_FILE_ACCESS_ERROR.","Align the PHP intl ICU version with the version used to compile the bundles."],"exampleFix":"// before\n$rb = new \\ResourceBundle('es', '/app/resources/messages'); // bundle only contains en, fr\n// after\n$locales = ['en', 'fr'];\nif (!in_array('es', $locales, true)) {\n    throw new \\RuntimeException('Locale es missing from ICU bundle; rebuild with msgfmt.');\n}","handlingStrategy":"try-catch","validationCode":"$rb = new \\ResourceBundle($locale, $basePath);\nif ($rb && intl_is_failure($rb->getErrorCode())) {\n    throw new \\RuntimeException('ICU failure '.$rb->getErrorCode().': '.$rb->getErrorMessage());\n}","typeGuard":"function intlBundleHealthy(\\ResourceBundle $rb): bool { return !intl_is_failure($rb->getErrorCode()); }","tryCatchPattern":"try {\n    $catalogue = $loader->load($basePath, $locale);\n} catch (Symfony\\Component\\Translation\\Exception\\InvalidResourceException $e) {\n    // $e->getCode() is the ICU error code (e.g. U_MISSING_RESOURCE_ERROR)\n    error_log('ICU error '.$e->getCode().': '.$e->getMessage());\n}","preventionTips":["Map ICU error codes in monitoring (codes are the exception code).","Include all required locales when building bundles.","Fix permissions/open_basedir so ICU can read bundle data files.","Keep PHP intl ICU data in sync with bundle compiler version."],"tags":["icu","intl","resource-bundle","translation","icu-error"],"backgroundTag":"file-read-failed","analyzedSha":"ae9e8a51bc29780d63c7f9efd6005d7c875e100b","analyzedAt":"2026-09-15T22:29:15.305Z","contentChangedAt":"2026-09-15T22:29:15.305Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}