[autotest] Make json_rpc raise meaningful exceptions

Add some dynamic suite exceptions to client/common_lib/error.py so
that different parts of the system can all reference them.  Then,
enable the json_rpc code to detect these exceptions coming back
over the wire, re-instantiate them on the client side, and raise
them.

BUG=chromium-os:30279
TEST=unit
TEST=use atest suite create to try to create a suite for a build that doesn't exist
TEST=use atest suite create to try to run a suite that doesn't exist

Change-Id: I1b6d56a7e1bdb63cc893a07581efc8decc0407f4
Reviewed-on: https://gerrit.chromium.org/gerrit/22250
Tested-by: Chris Masone <cmasone@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Ready: Chris Masone <cmasone@chromium.org>
diff --git a/frontend/afe/site_rpc_interface.py b/frontend/afe/site_rpc_interface.py
index 6e10504..818f3d1 100644
--- a/frontend/afe/site_rpc_interface.py
+++ b/frontend/afe/site_rpc_interface.py
@@ -8,14 +8,12 @@
 import datetime
 import logging
 import sys
-from autotest_lib.client.common_lib import global_config
+from autotest_lib.client.common_lib import error, global_config
 from autotest_lib.client.common_lib.cros import dev_server
 from autotest_lib.server.cros import control_file_getter, dynamic_suite
 
 
-class StageBuildFailure(Exception):
-    """Raised when the dev server throws 500 while staging a build."""
-    pass
+# Relevant CrosDynamicSuiteExceptions are defined in client/common_lib/error.py.
 
 
 class ControlFileEmpty(Exception):
@@ -74,7 +72,7 @@
     timings['download_started_time'] = datetime.datetime.now().strftime(
         time_fmt)
     if not ds.trigger_download(build, synchronous=False):
-        raise StageBuildFailure("Server error while staging " + build)
+        raise error.StageBuildFailure("Server error while staging " + build)
     timings['payload_finished_time'] = datetime.datetime.now().strftime(
         time_fmt)
 
@@ -82,7 +80,8 @@
     # Get the control file for the suite.
     control_file_in = getter.get_control_file_contents_by_name(suite_name)
     if not control_file_in:
-        raise ControlFileEmpty("Fetching %s returned no data." % suite_name)
+        raise error.ControlFileEmpty(
+            "Fetching %s returned no data." % suite_name)
 
     # prepend build and board to the control file
     inject_dict = {'board': board,