{"record":{"id":"cd26569f9aab8946","repo":"ssssssss-team/spider-flow","slug":"message","errorCode":null,"errorMessage":"{message}","messagePattern":"\\{message\\}","errorType":"exception","errorClass":"TemplateException","httpStatus":null,"severity":"error","filePath":"spider-flow-core/src/main/java/org/spiderflow/core/expression/ExpressionError.java","lineNumber":51,"sourceCode":"\n\t/** Create an error message based on the provided message and location, highlighting the location in the line on which the\n\t * error happened. Throws a {@link TemplateException} **/\n\tpublic static void error (String message, Span location, Throwable cause) {\n\n\t\tLine line = location.getLine();\n\t\tmessage = \"Error (\" + line.getLineNumber() + \"): \" + message + \"\\n\\n\";\n\t\tmessage += line.getText();\n\t\tmessage += \"\\n\";\n\n\t\tint errorStart = location.getStart() - line.getStart();\n\t\tint errorEnd = errorStart + location.getText().length() - 1;\n\t\tfor (int i = 0, n = line.getText().length(); i < n; i++) {\n\t\t\tboolean useTab = line.getText().charAt(i) == '\\t';\n\t\t\tmessage += i >= errorStart && i <= errorEnd ? \"^\" : useTab ? \"\\t\" : \" \";\n\t\t}\n\n\t\tif (cause == null)\n\t\t\tthrow new TemplateException(message, location);\n\t\telse\n\t\t\tthrow new TemplateException(message, location, cause);\n\t}\n\n\t/** Create an error message based on the provided message and location, highlighting the location in the line on which the\n\t * error happened. Throws a {@link TemplateException} **/\n\tpublic static void error (String message, Span location) {\n\t\terror(message, location, null);\n\t}\n\n\t/** Exception thrown by all basis-template code via {@link ExpressionError#error(String, Span)}. In case an error happens deep inside a\n\t * list of included templates, the {@link #getMessage()} method will return a condensed error message. **/\n\tpublic static class TemplateException extends RuntimeException {\n\t\tprivate static final long serialVersionUID = 1L;\n\t\tprivate final Span location;\n\t\tprivate final String errorMessage;\n\n\t\tprivate TemplateException (String message, Span location) {","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/ssssssss-team/spider-flow/blob/c799cca99c7d064673dc79e6ef06a08bbc0e292d/spider-flow-core/src/main/java/org/spiderflow/core/expression/ExpressionError.java#L33-L69","documentation":"ExpressionError.error builds a caret-highlighted message pointing at the failing span within the expression line and throws freemarker.template.TemplateException with that message and location. The '{message}' placeholder in the error record simply stands for the generated, location-annotated message text.","triggerScenarios":"Any failed expression evaluation routed through ExpressionError.error: invalid FreeMarker/Aviator expression syntax in a spider flow field, unknown variables in the expression, or a wrapped cause exception.","commonSituations":"Users type malformed expressions in the flow designer (unbalanced parentheses, wrong function name, referencing a variable that doesn't exist in context), or an expression worked in an older engine version but the syntax/variable changed.","solutions":["Read the caret position in the message to find the exact character range that failed, then correct the expression syntax there.","Verify all variables referenced in the expression exist in the execution context at that node.","Test the expression in isolation (evaluate just the expression against sample context) before re-running the flow."],"exampleFix":"// before (expression)\n${a.b.c}  // a is null\n// after\n${(a.b.c)!'default'}","handlingStrategy":"try-catch","validationCode":"// Validate expression before execution: try compiling it against a sample context\ntry { expressionService.compile(expr); } catch (Exception e) { /* surface syntax error to user before run */ }","typeGuard":null,"tryCatchPattern":"try {\n  Object v = expressionEngine.execute(expr, context);\n} catch (TemplateException e) {\n  // message contains caret-marked location of the failing span in the expression line\n  log.error(\"Expression failed: {}\", e.getMessage());\n}","preventionTips":["Use the caret position in the error message to pinpoint and fix the failing expression range.","Reference variables with null-safe defaults, e.g. ${(a.b)!'default'}.","Test expressions in the flow designer's expression evaluator before saving the flow."],"tags":["java","freemarker","expression","spider-flow"],"backgroundTag":"invalid-argument-format","analyzedSha":"c799cca99c7d064673dc79e6ef06a08bbc0e292d","analyzedAt":"2026-09-08T13:47:08.225Z","contentChangedAt":"2026-09-08T13:47:08.225Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}