Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YAMLのロード時の例外捕捉 #1797

Closed
kmuto opened this issue Feb 9, 2022 · 0 comments
Closed

YAMLのロード時の例外捕捉 #1797

kmuto opened this issue Feb 9, 2022 · 0 comments

Comments

@kmuto
Copy link
Owner

kmuto commented Feb 9, 2022

YAMLエラーのときに捕捉されず最後まで例外が飛んでしまう。
config.ymlで pdfmaker: をコメントしている状態で下位の makeindex: null を有効にするとか。

$ rake pdf
review-pdfmaker  config.yml
Traceback (most recent call last):
	11: from /home/kmuto/review/bin/review-pdfmaker:14:in `<main>'
	10: from /home/kmuto/review/lib/review/pdfmaker.rb:93:in `execute'
	 9: from /home/kmuto/review/lib/review/pdfmaker.rb:124:in `execute'
	 8: from /home/kmuto/review/lib/review/configure.rb:160:in `create'
	 7: from /home/kmuto/review/lib/review/yamlloader.rb:53:in `load_file'
	 6: from /home/kmuto/review/lib/review/yamlloader.rb:9:in `safe_load_file'
	 5: from /home/kmuto/review/lib/review/yamlloader.rb:9:in `open'
	 4: from /home/kmuto/review/lib/review/yamlloader.rb:12:in `block in safe_load_file'
	 3: from /usr/lib/ruby/2.7.0/psych.rb:349:in `safe_load'
	 2: from /usr/lib/ruby/2.7.0/psych.rb:390:in `parse'
	 1: from /usr/lib/ruby/2.7.0/psych.rb:456:in `parse_stream'
/usr/lib/ruby/2.7.0/psych.rb:456:in `parse': (/tmp/a/config.yml): did not find expected key while parsing a block mapping at line 8 column 1 (Psych::SyntaxError)
	4: from /home/kmuto/review/bin/review-pdfmaker:14:in `<main>'
	3: from /home/kmuto/review/lib/review/pdfmaker.rb:93:in `execute'
	2: from /home/kmuto/review/lib/review/pdfmaker.rb:124:in `execute'
	1: from /home/kmuto/review/lib/review/configure.rb:158:in `create'
/home/kmuto/review/lib/review/configure.rb:162:in `rescue in create': yaml error (/tmp/a/config.yml): did not find expected key while parsing a block mapping at line 8 column 1 (ReVIEW::ConfigError)
rake aborted!

手前で捕捉して妥当なエラーメッセージにする。

@kmuto kmuto closed this as completed in a1787c5 Feb 9, 2022
kmuto added a commit that referenced this issue Feb 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant