{"record":{"id":"2a99f992ded7e950","repo":"antlr/antlr4","slug":"antlr-errormanager-panic","errorCode":null,"errorMessage":"ANTLR ErrorManager panic","messagePattern":"ANTLR ErrorManager panic","errorType":"panic","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"tool/src/org/antlr/v4/tool/ErrorManager.java","lineNumber":314,"sourceCode":"\tpublic void panic(ErrorType errorType, Object... args) {\n\t\tToolMessage msg = new ToolMessage(errorType, args);\n\t\tST msgST = getMessageTemplate(msg);\n\t\tString outputMsg = msgST.render();\n\t\tif ( formatWantsSingleLineMessage() ) {\n\t\t\toutputMsg = outputMsg.replace('\\n', ' ');\n\t\t}\n\t\tpanic(outputMsg);\n\t}\n\n\tpublic static void panic(String msg) {\n\t\trawError(msg);\n\t\tpanic();\n\t}\n\n    public static void panic() {\n        // can't call tool.panic since there may be multiple tools; just\n        // one error manager\n        throw new Error(\"ANTLR ErrorManager panic\");\n    }\n}\n","sourceCodeStart":296,"sourceCodeEnd":317,"githubUrl":"https://github.com/antlr/antlr4/blob/7d5770395bb7b02eb56e7c62662cb1d7c08f42a3/tool/src/org/antlr/v4/tool/ErrorManager.java#L296-L317","documentation":"ErrorManager.panic() throws java.lang.Error('ANTLR ErrorManager panic') as the static, tool-independent abort for the error manager. The comment in source explains it cannot call tool.panic because multiple Tool instances may share one error manager. It signals a fatal, non-recoverable error condition during tool execution.","triggerScenarios":"Fatal error paths in ErrorManager (e.g. panic(msg) after rawError), format-string/internal errors while emitting messages, or direct calls to ErrorManager.panic().","commonSituations":"Malformed message formatting resources, corrupted tool distribution, or bug-level conditions while processing broken grammars.","solutions":["Look at the raw error message printed just before the panic — it names the real failure","Verify the antlr4 tool jar is intact and versions are consistent","Minimize the grammar and report if the panic reproduces on the current release"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { /* tool invocation */ } catch (Error e) { if (\"ANTLR ErrorManager panic\".equals(e.getMessage())) { /* fatal tool error; inspect logged raw error above */ } }","preventionTips":["Keep the ANTLR distribution intact (verify jar hashes after download)","Fix fatal grammar errors reported before the panic rather than catching it"],"tags":["antlr","error-manager","fatal","java"],"backgroundTag":null,"analyzedSha":"7d5770395bb7b02eb56e7c62662cb1d7c08f42a3","analyzedAt":"2026-08-14T14:47:56.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}