How to pick failed element in ruby

hello friends , i have experience in working with javascript. New in
ruby,
can anybody help me in picking up the element which got failed while
running my scripts. I want to store the name of the element that got
failed in a variable.

A failed element? Do you mean an error? Please explain exactly what’s
failing. Also consider showing some code and I’m sure we can help you.
It’s
just how you asked the question it seems a bit ambiguous.

Stu wrote in post #1130042:

A failed element? Do you mean an error? Please explain exactly what’s
failing. Also consider showing some code and I’m sure we can help you.
It’s
just how you asked the question it seems a bit ambiguous.

I am running a script in ruby. If my scripts fails i want to store the
error/ exception message in a variable.

On 12/07/2013 08:41 PM, Stu wrote:

can anybody help me in picking up the element which got failed while
running my scripts. I want to store the name of the element that got
failed in a variable.

--
Posted via http://www.ruby-forum.com/.

See https://www.ruby-forum.com/topic/125107#1129823

Justin C. wrote in post #1130108:

On 12/07/2013 08:41 PM, Stu wrote:

can anybody help me in picking up the element which got failed while
running my scripts. I want to store the name of the element that got
failed in a variable.

--
Posted via http://www.ruby-forum.com/.

See https://www.ruby-forum.com/topic/125107#1129823

begin

code

rescue Exception => e
@value =e.message
end

i used this its working fine

On 9/12/2013, at 8:13 PM, saurav panda [email protected] wrote:

begin

code

rescue Exception => e
@value =e.message
end

i used this its working fine

Works for me

irb(main):001:0> begin
irb(main):002:1* # code
irb(main):003:1*
irb(main):004:1* rescue Exception => e
irb(main):005:1> @value =e.message
irb(main):006:1> end
=> nil

And this

irb(main):007:0> begin
irb(main):008:1* fail
irb(main):009:1> rescue Exception => e
irb(main):010:1> @value =e.message
irb(main):011:1> end
=> “”
irb(main):012:0>

Henry

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs