dosubot[bot] commented on issue #586:
URL:
https://github.com/apache/incubator-hugegraph-toolchain/issues/586#issuecomment-1988938338
<!-- Answer -->
The `HugeClientUtil.java` file in the HugeGraph Hubble project uses the
`service.suspected-web` parameter from the `messages.properties` file to handle
a specific type of connection error. When the error message from a
`ClientException` contains the string `<!doctype html>`, it suggests that the
server is not a HugeGraph server but rather a web server. In this case, an
`ExternalException` is thrown with the `service.suspected-web` parameter as the
error code. Here is the relevant code snippet:
```java
} catch (ClientException e) {
Throwable cause = e.getCause();
if (cause == null || cause.getMessage() == null) {
throw e;
}
String message = cause.getMessage();
if (message.contains("Connection refused")) {
throw new ExternalException("service.unavailable", e, host, port);
} else if (message.contains("java.net.UnknownHostException") ||
message.contains("Host name may not be null")) {
throw new ExternalException("service.unknown-host", e, host);
} else if (message.contains("<!doctype html>")) {
throw new ExternalException("service.suspected-web",
e, host, port);
}
throw e;
}
```
This code block is designed to handle different types of connection errors
by throwing an `ExternalException` with a specific error code that can be
localized using the `messages.properties` file. The `service.suspected-web`
parameter is used as the error code when the response from the server is an
HTML document, which is not expected for a HugeGraph server connection.
You can find the `HugeClientUtil.java` file in the HugeGraph Hubble project
[here](https://github.com/apache/incubator-hugegraph-toolchain/blob/master/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/util/HugeClientUtil.java).
The `messages.properties` file is a properties file that contains key-value
pairs, where each key represents a specific message identifier and the value is
the message text itself. This file is used for internationalization (i18n)
purposes, allowing the application to support messages in multiple languages
easily by defining them in separate properties files. The
`service.suspected-web` parameter is one of the keys in this file.
You can find the `messages.properties` file in the HugeGraph Hubble project
[here](https://github.com/apache/incubator-hugegraph-toolchain/blob/master/hugegraph-hubble/hubble-be/src/main/resources/i18n/messages.properties).
I hope this answers your question. If you need further clarification, feel
free to ask.
## Sources
-
[hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/util/HugeClientUtil.java](https://github.com/apache/incubator-hugegraph-toolchain/blob/master/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/util/HugeClientUtil.java)
-
[hugegraph-hubble/hubble-be/src/main/resources/i18n/messages.properties](https://github.com/apache/incubator-hugegraph-toolchain/blob/master/hugegraph-hubble/hubble-be/src/main/resources/i18n/messages.properties)
<!-- Dosu Comment Footer -->
<details>
<summary>
#### About Dosu
</summary>
This response is meant to be useful and save you time. It is **not meant to
be a precise solution**, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is
irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]