Skip to content

Commit

Permalink
Add missing cause when throwing exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesChenX committed Dec 21, 2024
1 parent 4ad3b00 commit dcd1716
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ private Long closeOrUpdateSession(UserSession session, long nowNanos) {
t -> LOGGER.error(
"Caught an error while closing the local user session ({}) with the close reason: {}",
session,
HEARTBEAT_TIMEOUT));
HEARTBEAT_TIMEOUT,
t));
return null;
}
session.setLastHeartbeatUpdateTimestampNanos(nowNanos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private static Mono<Void> onConnected(
session.establish(ehloHostname, username, password, accessToken, startTls)
.subscribe(null, t -> {
LOGGER.error("Failed to establish the SMTP session: "
+ session.id);
+ session.id, t);
session.onClose(connectSink, t);
}, () -> {
LOGGER.info("Established the SMTP session: "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ private void notifyEndpointChangeListeners(Map<ApiEndpointKey, ApiEndpoint> keyT
} catch (Exception e) {
LOGGER.error("Caught an error while notifying the endpoint change listener: "
+ listener.getClass()
.getName());
.getName(),
e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public Mono<TurmsNotification> sendRequest(TurmsRequest.Builder requestBuilder)
@Override
public Mono<TurmsNotification> sendRequest(TurmsRequest request) {
if (connection == null) {
return Mono.error(new IllegalStateException("The connection has not established"));
return Mono.error(new IllegalStateException("The connection has not been established"));
}
if (connection.isDisposed()) {
return Mono.error(new IllegalStateException("The connection has been closed"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ private <T> Mono<Map<String, T>> requestResponsesAsMap(
.isActive()) {
return Mono.error(RpcException.get(RpcErrorCode.CONNECTION_NOT_FOUND,
ResponseStatusCode.SERVER_UNAVAILABLE,
"Some connections have not established"));
"Some connections have not been established"));
}
return Mono.deferContextual(context -> {
addTraceIdToRequestFromContext(context, request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,15 +468,15 @@ private void deleteLogFile(LogFile file) {
try {
Files.deleteIfExists(path);
} catch (Exception e) {
InternalLogger.INSTANCE.error("Caught an error while delete the log file: "
+ path);
InternalLogger.INSTANCE.error("Caught an error while deleting the log file: "
+ path, e);
}
if (archivePath != null) {
try {
Files.deleteIfExists(archivePath);
} catch (Exception e) {
InternalLogger.INSTANCE.error("Caught an error while delete the log file: "
+ archivePath);
InternalLogger.INSTANCE.error("Caught an error while deleting the log file: "
+ archivePath, e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ private Mono<Void> loadNetworkPlugin(HttpClient client, NetworkPluginProperties
} catch (Exception e) {
return Mono.error(new IllegalArgumentException(
"Invalid plugin URL: "
+ url));
+ url,
e));
}
String fileName = Paths.get(uri.getPath())
.getFileName()
Expand Down

0 comments on commit dcd1716

Please sign in to comment.