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

Message for yaml error #718

Merged
merged 3 commits into from Dec 31, 2012

Conversation

Projects
None yet
4 participants
@stereobooster
Contributor

stereobooster commented Dec 29, 2012

Resend PR for #498

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

This comment has been minimized.

@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

This comment has been minimized.

@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

This comment has been minimized.

@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

This comment has been minimized.

@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

This comment has been minimized.

@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

@stereobooster

This comment has been minimized.

Contributor

stereobooster commented Dec 30, 2012

Just founnd there was #591 PR merged

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

@jekyll jekyll 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.