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

Already on GitHub? Sign in to your account

Message for yaml error #718

Merged
merged 3 commits into from Dec 31, 2012

Conversation

Projects
None yet
4 participants
Contributor

stereobooster commented Dec 29, 2012

Resend PR for #498

@ixti ixti commented on the diff Dec 29, 2012

lib/jekyll/convertible.rb
@@ -25,14 +25,16 @@ def to_s
#
# Returns nothing.
def read_yaml(base, name)
- self.content = File.read(File.join(base, name))
-
begin
@ixti

ixti Dec 29, 2012

Member

there's no need for begin in this case. it can be something like:

def foo(bar, baz)
  self.content = File.read(File.join(base, name))

  if self.content =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m
    self.content = $POSTMATCH
    self.data = YAML.load($1)
  end
rescue SyntaxErrot => e
  puts "YAML Exception reading #{name}: #{e.message}"
rescue => e
  puts "YAML Exception reading #{name}: #{e.message}"
end
@stereobooster

stereobooster Dec 29, 2012

Contributor
    def read_yaml(base, name)
      begin
        self.content = File.read(File.join(base, name))

        if self.content =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m
          self.content = $POSTMATCH
          self.data = YAML.load($1)
        end
      rescue => e
        puts "Error reading file #{name}: #{e.message}"
      rescue SyntaxError => e
        puts "YAML Exception reading #{name}: #{e.message}"
      end

      self.data ||= {}
    end
@ixti

ixti Dec 29, 2012

Member
def foo(bar, baz)
  self.content = File.read(File.join(base, name))
  self.data = {}

  if self.content =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m
    self.content = $POSTMATCH
    self.data = YAML.load($1)
  end
rescue SyntaxErrot => e
  puts "YAML Exception reading #{name}: #{e.message}"
rescue => e
  puts "YAML Exception reading #{name}: #{e.message}"
end

:D

@stereobooster

stereobooster Dec 29, 2012

Contributor

What about return value in case of rescue?

rescue SyntaxErrot => e
  puts "YAML Exception reading #{name}: #{e.message}"
  self.data
rescue => e
  puts "YAML Exception reading #{name}: #{e.message}"
  self.data
end
@ixti

ixti Dec 29, 2012

Member

Ahhh. Sorry. Yes. In this case it's better leave it is in your original pull request.

@stereobooster stereobooster referenced this pull request Dec 30, 2012

Closed

YAML Error Messages #248

Contributor

stereobooster commented Dec 30, 2012

Just founnd there was #591 PR merged

@mojombo mojombo merged commit da096f3 into jekyll:master Dec 31, 2012

@jekyllbot jekyllbot locked and limited conversation to collaborators Feb 27, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.