Skip to content

Commit

Permalink
Improved error formatting for missing DSL methods
Browse files Browse the repository at this point in the history
  • Loading branch information
koraktor committed Feb 12, 2012
1 parent aa7c47c commit daf5d4a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/bundler/dsl.rb
Expand Up @@ -156,12 +156,13 @@ def env(name)

def method_missing(name, *args)
call = caller[0].split ':'
line = call[1]
content = Bundler.read_file(call[0]).lines.to_a[line.to_i - 1]
line = call[1].to_i
lines = ([0, line - 3].max)..line + 2
content = Bundler.read_file(call[0]).lines.to_a[lines].join(' ').strip

raise GemfileError, "The Gemfile doesn't support the method `#{name}`.\n" \
"Please check your Gemfile's syntax at line #{line}:\n\n" \
" #{content}"
" #{content}\n"
end

# Deprecated methods
Expand Down

0 comments on commit daf5d4a

Please sign in to comment.