Closed r0ckarong closed 4 years ago
So, this request is that if you have a topic file that is valid yaml, but malformed from asciibinder's perpective, you are expecting a better error message? If so, I agree...we probably should have a validation step immediately after parsing the yaml files.
Psych::SyntaxError: (
Building all distributions.
Error: Could not generate docs:
Psych::SyntaxError: (<unknown>): did not find expected key while parsing a block mapping at line 76 column 3 at
/Users/mnapp/.rvm/gems/ruby-2.4.0/gems/psych-2.2.4/lib/psych.rb:380:in `parse'
/Users/mnapp/.rvm/gems/ruby-2.4.0/gems/psych-2.2.4/lib/psych.rb:380:in `parse_stream'
/Users/mnapp/.rvm/gems/ruby-2.4.0/gems/psych-2.2.4/lib/psych.rb:463:in `load_stream'
/Users/mnapp/.rvm/gems/ruby-2.4.0/gems/ascii_binder-0.1.10.1/lib/ascii_binder/topic_map.rb:13:in `initialize'
/Users/mnapp/.rvm/gems/ruby-2.4.0/gems/ascii_binder-0.1.10.1/lib/ascii_binder/engine.rb:114:in `new'
/Users/mnapp/.rvm/gems/ruby-2.4.0/gems/ascii_binder-0.1.10.1/lib/ascii_binder/engine.rb:114:in `topic_map'
/Users/mnapp/.rvm/gems/ruby-2.4.0/gems/ascii_binder-0.1.10.1/lib/ascii_binder/engine.rb:336:in `block in generate_docs'
/Users/mnapp/.rvm/gems/ruby-2.4.0/gems/ascii_binder-0.1.10.1/lib/ascii_binder/engine.rb:308:in `each'
/Users/mnapp/.rvm/gems/ruby-2.4.0/gems/ascii_binder-0.1.10.1/lib/ascii_binder/engine.rb:308:in `generate_docs'
/Users/mnapp/.rvm/gems/ruby-2.4.0/gems/ascii_binder-0.1.10.1/bin/asciibinder:17:in `call_generate'
/Users/mnapp/.rvm/gems/ruby-2.4.0/gems/ascii_binder-0.1.10.1/bin/asciibinder:300:in `<top (required)>'
/Users/mnapp/.rvm/gems/ruby-2.4.0/bin/asciibinder:23:in `load'
/Users/mnapp/.rvm/gems/ruby-2.4.0/bin/asciibinder:23:in `<main>'
/Users/mnapp/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in `eval'
/Users/mnapp/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in `<main>'.
This means that one of the keys "below" the line displayed as erroneous is in the wrong indentation.
(WRONG)
Name: Something
Dir: something
Topics:
- Name: Something Else
File: something-else
- Name: Something More
File: something-more
Here something-more
is not contained in the something
directory but a level higher. Typically happens to me when rearranging structures.
(CORRECT)
Name: Something
Dir: something
Topics:
- Name: Something Else
File: something-else
- Name: Something More
File: something-more
@Fryguy Yes most of the errors you get when doing something bad are pure Ruby stacktraces that do not really bring your mistakes into context with AsciiBinder specific things. Especially when they are as striking as undefined method `[]' for nil:NilClass
.
When you know that certain error messages like the examples here typically coincide with a specific false use of formatting then it would be very nice to have an error message pointing the user in the right direction.
If it said "Error foo occured, looks like you have a wrong indentation in your topic map somewhere around line x". That would give me a much better indication that I made a mistake there and not with any other changes to the template files, graphics, etc.
Anything that emits a Psych::Syntax error is a YAML syntax error, and it would be very difficult for us to figure out how to create an error message on how the author could "correct" it, however I agree that we should catch that error and at a minimum reply with something like
ERROR: .topic_map.yml has a YAML syntax error:
did not find expected key while parsing a block mapping at line 76 column 3
A valid YAML, but missing asciibinder specifics, should error with something like
ERROR: .topic_map.yml has invalid content:
Topic named "Changelog v1.5.5" is missing the File attribute
I get error messages that I try to understand but don't make sense until after a lot of experimentation. Maybe you could add some exception handling that displays some more relevant info. For example:
no implicit conversion of String into Integer
Means that the YAML in the topic map is misformed and one of the entries can not be processed. For me the error was that I had removed a preceeding level of indentation but not removed the minus (-) at the beginning.
(WRONG)
(Correct)
Example 2:
NoMethodError: undefined method `[]' for nil:NilClass at
Means that you have a malformed line in the _topic_map.yml that can not be read.
For me I tried to have a placeholder comment instead of a new section.
(WRONG)
(Correct)