   defmacro with_response(response, do: block) do
     quote do
       response = unquote(response)
-      fault = response.body["Fault"]
-
-      if not is_nil(fault) do
-        error = fault["detail"]["Errors"]["ErrorDetail"]["PrimaryErrorCode"]
-        {:error, %{code: error["Code"], message: error["Description"]}}
-      else
-        unquote(block)
+      case response do
+        {:ok, response} ->
+          fault = response.body["Fault"]
+
+          if not is_nil(fault) do
+            error = fault["detail"]["Errors"]["ErrorDetail"]["PrimaryErrorCode"]
+            {:error, %{code: error["Code"], message: error["Description"]}}
+          else
+            var!(response) = response
+            unquote(block)
+          end
+
+        {:error, _} ->
+          {:error, %{code: 1, message: "The UPS API is down."}}
+
+        _ ->
+          {:error, %{code: 0, message: "Unknown error."}}
       end
     end
   end

      |> Map.merge(security_params)
      |> Map.merge(shipment_request_params(shipment, service))

    {:ok, response} = Client.post("/Ship", params, [{"Content-Type", "application/json"}])

    with_response response do
      body = response.body["ShipmentResponse"]

      |> Map.merge(security_params)
      |> Map.merge(xav_params)

    response = Client.post("/XAV", params, [{"Content-Type", "application/json"}])

    with_response response do
      body = response.body["XAVResponse"]
