{"record":{"id":"debc2164644d2f9c","repo":"stanfordnlp/CoreNLP","slug":"unsupported-format-format","errorCode":null,"errorMessage":"Unsupported format  + format","messagePattern":"Unsupported format  \\+ format","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/SemanticGraph.java","lineNumber":1492,"sourceCode":"   *\n   * </dl>\n   *\n   * @param format A {@code String} specifying the desired format\n   * @return A {@code String} representation of the typed dependencies in\n   *         this {@code GrammaticalStructure}\n   */\n  public String toString(OutputFormat format) {\n    switch(format) {\n    case XML:\n      return toXMLString();\n    case READABLE:\n      return toReadableString();\n    case LIST:\n      return toList();\n    case RECURSIVE:\n      return toString();\n    default:\n      throw new IllegalArgumentException(\"Unsupported format \" + format);\n    }\n  }\n\n  /**\n   * Returns a String representation of this graph as a list of typed\n   * dependencies, as exemplified by the following:\n   *\n   * <pre>\n   *  nsubj(died-6, Sam-3)\n   *  tmod(died-6, today-9)\n   * </pre>\n   *\n   * @return a {@code String} representation of this set of typed dependencies\n   */\n  public String toList() {\n    StringBuilder buf = new StringBuilder();\n    for (IndexedWord root : getRoots()) {\n      buf.append(\"root(ROOT-0, \");","sourceCodeStart":1474,"sourceCodeEnd":1510,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/SemanticGraph.java#L1474-L1510","documentation":"SemanticGraph.toString(SemanticGraphOutputFormat) throws IllegalArgumentException when the format enum has no handler in the switch, i.e. an output format was added to the enum but not supported here (only READABLE, LIST, RECURSIVE are handled).","triggerScenarios":"Calling sg.toString(format) with a SemanticGraphOutputFormat value outside the handled set, typically XML or any newly introduced format constant.","commonSituations":"Upgrading the Stanford parser to a version with new enum members while custom code switches over formats; passing XML expecting a String output when the API only supports the three formats.","solutions":["Use one of the supported formats: SemanticGraphOutputFormat.READABLE, LIST, or RECURSIVE","Check the SemanticGraphOutputFormat enum in your version and map unsupported values to a supported renderer (e.g. toXML if available)","Pin the parser version and re-check the switch when upgrading"],"exampleFix":"// before\nString s = sg.toString(SemanticGraphOutputFormat.XML);\n// after\nString s = sg.toString(SemanticGraphOutputFormat.READABLE);","handlingStrategy":"validation","validationCode":"if (format == SemanticGraphOutputFormat.READABLE || format == SemanticGraphOutputFormat.LIST || format == SemanticGraphOutputFormat.RECURSIVE) { String s = sg.toString(format); }","typeGuard":"boolean supported = format == SemanticGraphOutputFormat.READABLE || format == SemanticGraphOutputFormat.LIST || format == SemanticGraphOutputFormat.RECURSIVE;","tryCatchPattern":"try { s = sg.toString(format); } catch (IllegalArgumentException e) { s = sg.toString(SemanticGraphOutputFormat.READABLE); }","preventionTips":["Restrict format choices to the enum members handled in your CoreNLP version","Re-check switch coverage when upgrading parser versions","Default to READABLE for logging"],"tags":["java","nlp","enum","unsupported-format"],"backgroundTag":"unsupported-enum-value","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}