plantuml / backlog

Contains all issues for plantuml that are not currently working-in-progress
0 stars 0 forks source link

Option to throw ErrorUml #13

Open joaoe opened 5 years ago

joaoe commented 5 years ago

Hi !

I'm using Structurizr in my project, which uses plantuml. For unimportant reasons, structurizr generates some uml code that is not valid, e..g. empty title. My diagram is generated truncated with an error at the top Syntax error: title.

I'd like for plantuml not to generate and inject errors into my SVG diagram but instead to throw them so I can fix my program. As the program and diagram grows, it is quite unmaintainable to be debugging the output file manually to check for "syntax error".

So, suggestion: add flag to net.sourceforge.plantuml.OptionFlags like throwErrors and then each place an ErrorUml is created, throw it.

Thank you.

arnaudroques commented 5 years ago

Good idea! With last version 1.2018.13, there is a setSilentlyCompletelyIgnoreErrors(boolean) in OptionFlagsclass. Currently it's only active in SourceFileReader class which may be not enough for you. Can you tell us how you are integrating with PlantUML ?

Thanks,

joaoe commented 5 years ago

I'm using Structurizr [1], which does not do any input validation, and then generates UML markup which apparently causes problems. Thank you.

[1] My code pretty much looks like this

// My code: fill in the model/workspace
Workspace workspace = new Workspace("title", "desc");

// Structurizr
StringWriter sw = new StringWriter();
PlantUMLWriter puw = new PlantUMLWriter()
puw.write(workspace, sw);

// And PlantUML
for (String section: sw.toString().split("(?=@startuml)")) {
  SourceStringReader reader = new SourceStringReader(section);
  reader.generateImage(os, new FileFormatoption(FileFormat.SVG));
  // write os to file
}