N
Nathan Beyer
What's the distinction between:
raise ArgumentError, "the argument was invalid"
and
raise ArgumentError.new("the argument was invalid")
How does this apply in the case of exceptions with custom initializers
for attributes? For example:
class StatusCodeError < StandardError
attr_reader :status_code
def initialize(status_code)
@status_code = status_code
end
end
I've been reading a lot of code, books and blogs, but haven't gotten
as clear of an understanding on why people choose one way over
another, so I'm looking for additional opinions and commentary.
Thanks
raise ArgumentError, "the argument was invalid"
and
raise ArgumentError.new("the argument was invalid")
How does this apply in the case of exceptions with custom initializers
for attributes? For example:
class StatusCodeError < StandardError
attr_reader :status_code
def initialize(status_code)
@status_code = status_code
end
end
I've been reading a lot of code, books and blogs, but haven't gotten
as clear of an understanding on why people choose one way over
another, so I'm looking for additional opinions and commentary.
Thanks