begin
hash = {"a" => "b"}
raise hash
rescue Exception => e
p e.message
end
Why i am not getting raised hash object in result, instead i am getting error - "exception class/object expected"
Here's you're getting an error about the way that you're raising an error.
When you say raise
you need to pass it an "exception class/object".
Some examples using built-in errors
raise(StandardError, "my message")
raise ArgumentError, "message"
raise NoMethodError
And creating a custom error class:
class MyError < StandardError
end
raise MyError, "message"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With