Skip to content

Commit

Permalink
Add caller file and line to Nil#not_nil! (crystal-lang#6712)
Browse files Browse the repository at this point in the history
  • Loading branch information
Maria Kim authored and sdogruyol committed Sep 13, 2018
1 parent ee71249 commit 9c2e741
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/nil.cr
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ struct Nil
end

# Raises an exception.
# Reports the file and line at which the `not_nil!` assertion is called.
#
# See also: `Object#not_nil!`.
def not_nil!
raise "Nil assertion failed"
def not_nil!(caller_file = __FILE__, caller_line = __LINE__)
raise "Nil assertion failed at #{caller_file}:#{caller_line}"
end

def clone
Expand Down

0 comments on commit 9c2e741

Please sign in to comment.