Skip to content
New issue

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

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ContractError should also show the arguments that caused the error #231

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/contracts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def to_s
("#{args} => #{ret}").gsub("Contracts::Builtin::", "")
end

# Given a hash, prints out a failure message.
# Given a hash, returns a failure message.
# This function is used by the default #failure_callback method
# and uses the hash passed into the failure_callback method.
def self.failure_msg(data)
Expand All @@ -130,6 +130,7 @@ def self.failure_msg(data)
Actual: #{data[:arg].inspect}
Value guarded in: #{data[:class]}::#{method_name}
With Contract: #{data[:contracts]}
All arguments: #{data[:args].inspect}
At: #{position} }
end

Expand Down
3 changes: 3 additions & 0 deletions lib/contracts/call_with.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def call_with(this, *args, &blk)
:contracts => self,
:arg_pos => i+1,
:total_args => args.size,
:args => args,
:return_value => false)
end

Expand Down Expand Up @@ -56,6 +57,7 @@ def call_with(this, *args, &blk)
:contracts => self,
:arg_pos => i-1,
:total_args => args.size,
:args => args,
:return_value => false)
end

Expand All @@ -82,6 +84,7 @@ def call_with(this, *args, &blk)
:class => klass,
:method => method,
:contracts => self,
:args => args,
:return_value => true)
end

Expand Down