SeleniumHQ/selenium — pull request #220 by Jonahss (2014-05-15 21:06:45+00:00)
Title: allow custom ErrorHandler for HTTPCommandExecutor

I recently wrote a client which extends the RemoteWebDriver. There was really good support in place for adding new Commands to the HTTPCommandExecutor, but adding custom error codes was much more cumbersome.

Here I added a setErrorHandler() method to the HTTPCommandExecutor. I felt that adding is as a parameter to the constructor would unnecessarily create way too many permutations of constructor arguments.

I also added a new constructor for the ErrorHandler class which accepts a custom ErrorCodes object. There weren't so many constructors on the ErrorHandler class, so thought it more appropriate than adding a setter method.

Are these changes all right? Something a bit more drastic, but possibly cleaner would be to make an Error object which is essentially a triplet {code, state message, java exception class}. Then the ErrorCodes class can be easily extensible, and just consist of a collection of Error objects rather than having hardcoded select..case statements.