Commit bf474663 authored by anonym's avatar anonym
Browse files

Throw a native Ruby exception in findAny/waitAny.

Rjb::throw doesn't seem to block Ruby's execution until the Java
exception has been received by Ruby, so strange things can happen.
parent 03f2d9c0
...@@ -74,6 +74,12 @@ end ...@@ -74,6 +74,12 @@ end
sikuli_script_proxy = Sikuli::Screen sikuli_script_proxy = Sikuli::Screen
$_original_sikuli_screen_new ||= Sikuli::Screen.method :new $_original_sikuli_screen_new ||= Sikuli::Screen.method :new
# For waitAny()/findAny() we are forced to throw this exception since
# Rjb::throw doesn't block until the Java exception has been received
# by Ruby, so strange things can happen.
class FindAnyFailed < StandardError
end
def sikuli_script_proxy.new(*args) def sikuli_script_proxy.new(*args)
s = $_original_sikuli_screen_new.call(*args) s = $_original_sikuli_screen_new.call(*args)
...@@ -163,8 +169,8 @@ def sikuli_script_proxy.new(*args) ...@@ -163,8 +169,8 @@ def sikuli_script_proxy.new(*args)
end end
end end
# If we've reached this point, none of the images could be found. # If we've reached this point, none of the images could be found.
Rjb::throw('org.sikuli.script.FindFailed', raise FindAnyFailed.new("can not find any of the images #{images} on the " +
"can not find any of the images #{images} on the screen") "screen")
end end
def s.waitAny(images, time) def s.waitAny(images, time)
...@@ -175,8 +181,8 @@ def sikuli_script_proxy.new(*args) ...@@ -175,8 +181,8 @@ def sikuli_script_proxy.new(*args)
end end
end end
rescue Timeout::Error rescue Timeout::Error
Rjb::throw('org.sikuli.script.FindFailed', raise FindAnyFailed.new("can not find any of the images #{images} on the " +
"can not find any of the images #{images} on the screen") "screen")
end end
def s.hover_point(x, y) def s.hover_point(x, y)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment