structurizr / cli

A command line utility for Structurizr.
https://docs.structurizr.com/cli
Apache License 2.0
492 stars 75 forks source link

Handle exception to show line number of parsing errors #86

Closed dgutson closed 1 year ago

dgutson commented 1 year ago

Currently, when there's something wrong with the input DSL, I get this output:

 - loading workspace from DSL
com.structurizr.dsl.StructurizrDslParserException: Unexpected tokens
        at com.structurizr.dsl.StructurizrDslParser.parse(StructurizrDslParser.java:774)
        at com.structurizr.dsl.StructurizrDslParser.parse(StructurizrDslParser.java:125)
        at com.structurizr.cli.export.ExportCommand.run(ExportCommand.java:126)
        at com.structurizr.cli.StructurizrCliApplication.run(StructurizrCliApplication.java:77)
        at com.structurizr.cli.StructurizrCliApplication.main(StructurizrCliApplication.java:112)
com.structurizr.dsl.StructurizrDslParserException: Unexpected tokens at line 256: c4plantuml.sprite robot
        at com.structurizr.dsl.StructurizrDslParser.parse(StructurizrDslParser.java:787)
        at com.structurizr.dsl.StructurizrDslParser.parse(StructurizrDslParser.java:125)
        at com.structurizr.cli.export.ExportCommand.run(ExportCommand.java:126)
        at com.structurizr.cli.StructurizrCliApplication.run(StructurizrCliApplication.java:77)
        at com.structurizr.cli.StructurizrCliApplication.main(StructurizrCliApplication.java:112)

The important part for the user is Unexpected tokens at line 256: c4plantuml.sprite robot

I'm suggesting to handle the exception in order to show just the error part for a better user experience.