+++ /dev/null
-package io.bytom.offline.exception;\r
-\r
-import com.squareup.okhttp.Response;\r
-\r
-import java.io.IOException;\r
-\r
-/**\r
- * ConnectivityException wraps errors due to connectivity issues with the server.\r
- */\r
-public class ConnectivityException extends BytomException {\r
- /**\r
- * Initializes exception with its message attribute.\r
- *\r
- * @param resp the server response used to create error message\r
- */\r
- public ConnectivityException(Response resp) {\r
- super(formatMessage(resp));\r
- }\r
-\r
- /**\r
- * Parses the the server response into a detailed error message.\r
- *\r
- * @param resp the server response\r
- * @return detailed error message\r
- */\r
- private static String formatMessage(Response resp) {\r
- String s =\r
- "Response HTTP header field Chain-Request-ID is unset. There may be network issues. Please check your local network settings.";\r
- // TODO(kr): include client-generated reqid here once we have that.\r
- String body;\r
- try {\r
- body = resp.body().string();\r
- } catch (IOException ex) {\r
- body = "[unable to read response body: " + ex.toString() + "]";\r
- }\r
- return String.format("%s status=%d body=%s", s, resp.code(), body);\r
- }\r
-}\r