lutaml / lutaml-uml

UML module for LutaML
2 stars 2 forks source link

(Feature) Parsing failure of files should provide better messages #89

Closed w00lf closed 3 years ago

w00lf commented 3 years ago

https://github.com/lutaml/lutaml-uml/issues/71 update to the latest parslet version(2.0.0), use Parslet::ErrorReporter::Deepest for error report, display the actual error place.

After that the error display became something like this:

$: bundle exec ./exe/lutaml -t png -o OfferingDoc_DataTypes.png /Users/mikhailtretiakov/Work/Personal/Metanorma/lutaml-uml/spec/fixtures/dsl/broken_diagram.lutaml
bundler: failed to load command: ./exe/lutaml (./exe/lutaml)
Lutaml::Uml::Parsers::ParsingError: Failed to match sequence (WHITESPACE? DIAGRAM_DEFINITION) at line 1 char 1.
cause: Failed to match sequence (WHITESPACE? DIAGRAM_DEFINITION) at line 1 char 1.
`- Failed to match sequence (DIAGRAM_KEYWORD SPACES? name:CLASS_NAME DIAGRAM_BODY WHITESPACE?) at line 1 char 16.
   `- Failed to match sequence (SPACES? '{' WHITESPACE? members:(DIAGRAM_INNER_DEFINITION{0, }) '}') at line 24 char 13.
      `- Expected "}", but got ":" at line 25 char 32.

  /Users/mikhailtretiakov/Work/Personal/Metanorma/lutaml-uml/lib/lutaml/uml/parsers/dsl.rb:32:in `rescue in parse'
  /Users/mikhailtretiakov/Work/Personal/Metanorma/lutaml-uml/lib/lutaml/uml/parsers/dsl.rb:23:in `parse'
  /Users/mikhailtretiakov/Work/Personal/Metanorma/lutaml-uml/lib/lutaml/uml/parsers/dsl.rb:20:in `parse'
  /Users/mikhailtretiakov/Work/Personal/Metanorma/lutaml/lib/lutaml/parser.rb:47:in `block in parse_into_document'

The script will point to the exact place where the error occurred.

ronaldtse commented 3 years ago

Thanks @w00lf !