Skip to content

Commit

Permalink
Show DSLError when theres a SyntaxError
Browse files Browse the repository at this point in the history
  • Loading branch information
segiddins committed May 15, 2015
1 parent f358c3b commit 41e06a9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# CocoaPods Core Changelog

## Master

##### Enhancements

* A more useful DSLError will be shown when there are syntax errors in a Ruby
Podfile or Podspec.
[Samuel Giddins](https://github.com/segiddins)
[CocoaPods#2651](https://github.com/CocoaPods/CocoaPods/issues/2651)


## 0.37.1

This version only introduces changes in the CocoaPods gem.
Expand Down
4 changes: 3 additions & 1 deletion lib/cocoapods-core/podfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,16 @@ def self.from_ruby(path)
string.encode!('UTF-8')
end
podfile = Podfile.new(path) do
# rubocop:disable Lint/RescueException
begin
# rubocop:disable Eval
eval(string, nil, path.to_s)
# rubocop:enable Eval
rescue => e
rescue Exception => e
message = "Invalid `#{path.basename}` file: #{e.message}"
raise DSLError.new(message, path, e.backtrace, string)
end
# rubocop:enable Lint/RescueException
end
podfile
end
Expand Down
5 changes: 4 additions & 1 deletion lib/cocoapods-core/specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,10 @@ def self._eval_podspec(string, path)
# rubocop:disable Eval
eval(string, nil, path.to_s)
# rubocop:enable Eval
rescue => e

# rubocop:disable Lint/RescueException
rescue Exception => e
# rubocop:enable Lint/RescueException
message = "Invalid `#{path.basename}` file: #{e.message}"
raise DSLError.new(message, path, e.backtrace, string)
end
Expand Down

0 comments on commit 41e06a9

Please sign in to comment.