Skip to content

Commit 50b6642

Browse files
committed
Handle yaml file missing
1 parent 9fbbdce commit 50b6642

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/matrixeval/ruby/config/yaml.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ module Matrixeval
22
module Ruby
33
class Config
44
class YAML
5+
6+
class MissingError < StandardError; end
7+
58
class << self
69

710
def create
@@ -25,6 +28,8 @@ def [](key)
2528
end
2629

2730
def yaml
31+
raise MissingError unless File.exist?(path)
32+
2833
::YAML.load File.read(path)
2934
end
3035

lib/matrixeval/ruby/runner.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ def start
3838
See 'matrixeval --help'
3939
ERROR
4040
exit
41+
rescue Config::YAML::MissingError
42+
puts "Please run 'matrixeval init' first to generate matrixeval.yml"
43+
exit
4144
ensure
4245
turn_on_stty_opost
4346
end

0 commit comments

Comments
 (0)