Skip to content

Commit

Permalink
Add NotSupportedError.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Perez committed Mar 22, 2016
1 parent b94d8ae commit e338a86
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/hound/exceptions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,14 @@ defmodule Hound.InvalidElementError do
"Could not transform value #{inspect(err.value)} to element"
end
end

defmodule Hound.NotSupportedError do
defexception [:function, :browser, :driver]

def message(err) do
{:ok, info} = Hound.ConnectionServer.driver_info
driver = err.driver || info.driver
browser = err.browser || info.browser
"#{err.function} is not supported by driver #{driver} with browser #{browser}"
end
end
17 changes: 17 additions & 0 deletions test/exceptions_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
defmodule HoundNotSupportedErrorTest do
use ExUnit.Case

test "message" do
{:ok, info} = Hound.ConnectionServer.driver_info
function_name = "foo"
err = try do
raise Hound.NotSupportedError, function: function_name
rescue
e -> Exception.message(e)
end
assert err =~ "not supported"
assert err =~ function_name
assert err =~ info.driver
assert err =~ info.browser
end
end

0 comments on commit e338a86

Please sign in to comment.