{"record":{"id":"c3b800f34aaf5a06","repo":"stanfordnlp/CoreNLP","slug":"is-an-unsupported-outputstyle","errorCode":null,"errorMessage":" is an unsupported OutputStyle","messagePattern":" is an unsupported OutputStyle","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/sequences/PlainTextDocumentReaderAndWriter.java","lineNumber":256,"sourceCode":"        printAnswersTokenizedInlineXML(l, out);\n      }\n      break;\n      case TSV:\n        if (preserveSpacing) {\n          printAnswersAsIsTextTsv(l, out);\n        } else {\n          printAnswersTokenizedTextTsv(l, out);\n        }\n        break;\n      case TABBED:\n        if (preserveSpacing) {\n          printAnswersAsIsTextTabbed(l, out);\n        } else {\n          printAnswersTokenizedTextTabbed(l, out);\n        }\n        break;\n    default:\n      throw new IllegalArgumentException(outputStyle +\n                                         \" is an unsupported OutputStyle\");\n    }\n  }\n\n  private static <IN extends CoreMap> void printAnswersTokenizedText(List<IN> l, PrintWriter out) {\n    for (IN wi : l) {\n      out.print(StringUtils.getNotNullString(wi.get(CoreAnnotations.TextAnnotation.class)));\n      out.print('/');\n      out.print(StringUtils.getNotNullString(wi.get(CoreAnnotations.AnswerAnnotation.class)));\n      out.print(' ');\n    }\n    out.println(); // put a single newline at the end [added 20091024].\n  }\n\n  private static <IN extends CoreMap> void printAnswersAsIsText(List<IN> l, PrintWriter out) {\n    for (IN wi : l) {\n      out.print(StringUtils.getNotNullString(wi.get(CoreAnnotations.BeforeAnnotation.class)));\n      out.print(StringUtils.getNotNullString(wi.get(CoreAnnotations.TextAnnotation.class)));","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/sequences/PlainTextDocumentReaderAndWriter.java#L238-L274","documentation":"PlainTextDocumentReaderAndWriter.printAnswers selects a printing routine based on the configured OutputStyle. The switch's default branch throws IllegalArgumentException if the outputStyle constant is not one of the handled styles — normally only reachable if a new OutputStyle constant was added without updating printAnswers, or the style was set programmatically to an unexpected value.","triggerScenarios":"Calling printAnswers / getAnswers / runTaggerSGML with a writer whose outputStyle is an OutputStyle constant not covered by the switch (e.g. a newly added enum value or one set via reflection/setOutputStyle).","commonSituations":"Extending or upgrading Stanford NLP where a custom/new OutputStyle was introduced but printAnswers was not updated; wiring an OutputStyle object directly instead of using fromShortName-parsed values.","solutions":["Set outputStyle to one of the supported constants handled by printAnswers (e.g. via OutputStyle.fromShortName with a valid short name).","If you added a new OutputStyle enum constant, add a case for it in printAnswers.","Check for library version mixing (jar on classpath differing from compiled-against version) and align versions."],"exampleFix":"// before\nprops.setProperty(\"outputStyle\", \"fancy\");\n// after\nprops.setProperty(\"outputStyle\", \"tsv\");","handlingStrategy":"validation","validationCode":"OutputStyle style = PlainTextDocumentReaderAndWriter.OutputStyle.fromShortName(props.getProperty(\"outputStyle\"));\n// ensure it is one of the styles handled by printAnswers before tagging","typeGuard":null,"tryCatchPattern":"try {\n  writer.printAnswers(l, out);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().endsWith(\"is an unsupported OutputStyle\")) {\n    log.error(\"Unsupported OutputStyle: \" + e.getMessage());\n  } else throw e;\n}","preventionTips":["Only set outputStyle via OutputStyle.fromShortName with registered short names.","If adding enum constants, update printAnswers' switch in the same change.","Keep Stanford NLP jar versions consistent on the classpath."],"tags":["enum","configuration","nlp","unsupported-value"],"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-17T15:17:12.973Z"}